{ "version": 3, "sources": ["../../app/assets/shared/components/confirm_account_deletion.js", "../../app/assets/shared/components/data_confirm.js", "../../app/assets/shared/components/foldable.js", "../../app/assets/shared/components/input_type_number.js", "../../app/assets/shared/components/invalid_input.js", "../../../../shared/node_modules/lazysizes/lazysizes.js", "../../app/assets/shared/components/query_diet.js", "../../app/assets/shared/components/video.js", "../../app/assets/frontend/components/accept_on_change.js", "../../app/assets/frontend/components/active_on_clicked.js", "../../app/assets/frontend/components/alert_message_on_click.js", "../../app/assets/frontend/components/app_status.js", "../../app/assets/frontend/components/code_search.js", "../../app/assets/frontend/components/content_code_search.js", "../../app/assets/frontend/components/full_avatar.js", "../../app/assets/frontend/components/fullscreen.js", "../../app/assets/frontend/components/go_back.js", "../../app/assets/frontend/components/image_in_lightbox.js", "../../app/assets/frontend/components/javascript_links.js", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/BitMatrix.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/binarizer/index.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/decodeData/BitStream.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/decodeData/index.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/reedsolomon/GenericGFPoly.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/reedsolomon/GenericGF.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/reedsolomon/index.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/version.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/decoder/decoder.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/extractor/index.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/locator/index.ts", "../../../../shared/node_modules/qr-scanner/node_modules/jsqr-es6/src/index.ts", "../../../../shared/node_modules/qr-scanner/src/worker.ts", "../../app/assets/frontend/components/readonly_checkboxes.js", "../../app/assets/frontend/components/scale_to_fill_container.js", "../../app/assets/frontend/components/scrollable_pagination.js", "../../app/assets/frontend/components/service_worker.js", "../../app/assets/frontend/components/slide_form.js", "../../../../shared/node_modules/unpoly/unpoly.js", "../../app/assets/shared/util/environment.js", "../../app/assets/shared/config/unpoly.js", "../../app/assets/frontend/util/current_user.js", "../../app/assets/frontend/config/unpoly.js", "../../app/assets/shared/util/load_script.js", "../../app/assets/shared/components/animated_icon.js", "import-glob:./shared/components/**/*.js", "../../app/assets/shared/util/application.js", "../../app/assets/shared/util/timeout.js", "../../app/assets/shared/components/flash_message.js", "../../app/assets/shared/components/lazysizes.js", "import-glob:./frontend/components/**/*.js", "../../../../shared/node_modules/ismobilejs/src/isMobile.ts", "../../app/assets/frontend/components/add_to_homescreen.js", "../../app/assets/frontend/util/device_type.js", "../../app/assets/frontend/components/autofocus_only_desktop.js", "../../../../shared/node_modules/autosize/dist/autosize.esm.js", "../../app/assets/frontend/components/autosize.js", "../../app/assets/frontend/util/fix_caret_position.js", "../../app/assets/frontend/components/code_search_field.js", "../../app/assets/frontend/util/callback_registry.js", "../../app/assets/frontend/util/game_state.js", "../../app/assets/frontend/components/course-navigation-submit.js", "../../app/assets/frontend/components/course_units_scroller.js", "../../app/assets/frontend/components/game.js", "../../app/assets/frontend/util/blanks_text.js", "../../../../shared/node_modules/sortablejs/modular/sortable.core.esm.js", "../../app/assets/frontend/util/sortable.js", "../../app/assets/frontend/util/sortable_with_single_drop_targets.js", "../../app/assets/frontend/util/set_notification.js", "../../app/assets/frontend/components/game_slide_blanks_text.js", "../../app/assets/frontend/util/derangement.js", "../../app/assets/frontend/util/nugget_comparator.js", "../../app/assets/frontend/util/grid_game.js", "../../app/assets/frontend/util/nugget_finder.js", "../../app/assets/frontend/components/game_slide_grid.js", "../../app/assets/frontend/util/image_assignment.js", "../../app/assets/frontend/components/game_slide_image_assignment.js", "../../../../shared/node_modules/qr-scanner/src/qr-scanner.ts", "../../app/assets/frontend/components/layout.js", "../../app/assets/frontend/components/login_code_field.js", "../../app/assets/frontend/util/analytics.js", "../../app/assets/frontend/components/qr_scanner.js", "../../app/assets/frontend/util/question.js", "../../app/assets/frontend/components/question.js", "../../app/assets/frontend/components/read_aloud.js", "../../app/assets/frontend/components/track_page_view.js", "../../../../shared/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs", "../../../../shared/node_modules/@floating-ui/core/dist/floating-ui.core.mjs", "../../../../shared/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs", "../../../../shared/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs", "../../app/assets/frontend/components/translation.js", "../../app/assets/frontend/util/video_play_button.js", "../../app/assets/frontend/components/video_multiple_choice.js", "../../app/assets/frontend/components/video_slide.js"], "sourcesContent": ["up.compiler('[confirm-account-deletion]', (element) => {\n\n const message = 'Zum dauerhaften L\u00F6schen deines Accounts, tippe bitte das Wort L\u00D6SCHEN ein.'\n const requiredInput = 'L\u00D6SCHEN'\n\n function onClick(event) {\n const input = prompt(message)\n const sanitizedInput = (input || '').trim().toUpperCase()\n const expectedInput = requiredInput.trim().toUpperCase()\n\n if (input === null) {\n alert('Du hast abgebrochen. Dein Account wurde nicht gel\u00F6scht.')\n event.preventDefault()\n } else if (sanitizedInput !== expectedInput) {\n alert(`Deine Eingabe war \u201E${sanitizedInput}\u201C statt \u201E${expectedInput}\u201C. Dein Account wurde nicht gel\u00F6scht.`)\n event.preventDefault()\n } else {\n // submit form to delete account\n }\n }\n\n element.addEventListener('click', onClick)\n\n})\n", "up.compiler('[data-confirm]', (element) => {\n\n function onClick(event) {\n const message = element.getAttribute('data-confirm')\n if (!confirm(message)) up.event.halt(event)\n }\n\n element.addEventListener('click', onClick)\n})\n", "up.compiler('[foldable]', (element) => {\n\n const foldableTriggers = element.querySelectorAll('[foldable--trigger]')\n const foldableContent = element.querySelector('[foldable--content]')\n const foldableIconExpanded = element.querySelector('[foldable--icon-expanded]')\n const foldableIconCollapsed = element.querySelector('[foldable--icon-collapsed]')\n\n foldableTriggers.forEach((trigger) => {\n trigger.addEventListener('click', () => {\n up.element.toggle(foldableContent)\n up.element.toggle(foldableIconExpanded)\n up.element.toggle(foldableIconCollapsed)\n if (up.element.isVisible(foldableContent)) {\n up.reveal(foldableContent, { padding: 30 })\n }\n })\n })\n\n})\n", "up.compiler('input[type=\"number\"]', (element) => {\n\n // Number inputs allow incrementing/decrementing with arrow keys, and support exponential notation\n // (in some browsers even regular letters). We want neither.\n element.addEventListener('keydown', (event) => {\n const key = event.key\n if (key === 'ArrowUp' || key === 'ArrowDown' || (key.length === 1 && !event.ctrlKey && !event.altKey && !key.match(/[0-9\\-+,.]/))) {\n event.preventDefault()\n }\n })\n\n // Some browser (at least Firefox) will increment/decrement a number when using the mouse's scroll wheel\n // above a focused number input. Since this can lead to users changing values by accident, we want to avoid that.\n element.addEventListener('wheel', (event) => {\n if (element.matches(':focus')) {\n event.preventDefault()\n }\n })\n\n})\n", "const selector = ['input', 'textarea', 'select']\n .map(tagName => `${tagName}.is-invalid`)\n .join(', ')\n\nup.compiler(selector, (element) => {\n\n const inputGroup = element.closest('.input-group')\n const formGroup = element.closest('.form-group')\n\n function setInputGroupInvalid(isInvalid) {\n inputGroup?.classList?.toggle('is-invalid', isInvalid)\n }\n\n function unsetOtherFormGroupFieldsInvalid() {\n if (formGroup) {\n Array.from(formGroup.querySelectorAll('.is-invalid')).forEach((element) => {\n element.classList.remove('is-invalid')\n })\n formGroup.querySelector('.invalid-feedback.d-block')?.classList?.remove('d-block')\n }\n }\n\n function unsetInvalid() {\n element.classList.remove('is-invalid')\n unsetOtherFormGroupFieldsInvalid()\n setInputGroupInvalid(false)\n }\n\n setInputGroupInvalid(true)\n element.addEventListener('input', unsetInvalid, { once: true })\n\n})\n", "(function(window, factory) {\n\tvar lazySizes = factory(window, window.document, Date);\n\twindow.lazySizes = lazySizes;\n\tif(typeof module == 'object' && module.exports){\n\t\tmodule.exports = lazySizes;\n\t}\n}(typeof window != 'undefined' ?\n window : {}, \n/**\n * import(\"./types/global\")\n * @typedef { import(\"./types/lazysizes-config\").LazySizesConfigPartial } LazySizesConfigPartial\n */\nfunction l(window, document, Date) { // Pass in the window Date function also for SSR because the Date class can be lost\n\t'use strict';\n\t/*jshint eqnull:true */\n\n\tvar lazysizes,\n\t\t/**\n\t\t * @type { LazySizesConfigPartial }\n\t\t */\n\t\tlazySizesCfg;\n\n\t(function(){\n\t\tvar prop;\n\n\t\tvar lazySizesDefaults = {\n\t\t\tlazyClass: 'lazyload',\n\t\t\tloadedClass: 'lazyloaded',\n\t\t\tloadingClass: 'lazyloading',\n\t\t\tpreloadClass: 'lazypreload',\n\t\t\terrorClass: 'lazyerror',\n\t\t\t//strictClass: 'lazystrict',\n\t\t\tautosizesClass: 'lazyautosizes',\n\t\t\tfastLoadedClass: 'ls-is-cached',\n\t\t\tiframeLoadMode: 0,\n\t\t\tsrcAttr: 'data-src',\n\t\t\tsrcsetAttr: 'data-srcset',\n\t\t\tsizesAttr: 'data-sizes',\n\t\t\t//preloadAfterLoad: false,\n\t\t\tminSize: 40,\n\t\t\tcustomMedia: {},\n\t\t\tinit: true,\n\t\t\texpFactor: 1.5,\n\t\t\thFac: 0.8,\n\t\t\tloadMode: 2,\n\t\t\tloadHidden: true,\n\t\t\tricTimeout: 0,\n\t\t\tthrottleDelay: 125,\n\t\t};\n\n\t\tlazySizesCfg = window.lazySizesConfig || window.lazysizesConfig || {};\n\n\t\tfor(prop in lazySizesDefaults){\n\t\t\tif(!(prop in lazySizesCfg)){\n\t\t\t\tlazySizesCfg[prop] = lazySizesDefaults[prop];\n\t\t\t}\n\t\t}\n\t})();\n\n\tif (!document || !document.getElementsByClassName) {\n\t\treturn {\n\t\t\tinit: function () {},\n\t\t\t/**\n\t\t\t * @type { LazySizesConfigPartial }\n\t\t\t */\n\t\t\tcfg: lazySizesCfg,\n\t\t\t/**\n\t\t\t * @type { true }\n\t\t\t */\n\t\t\tnoSupport: true,\n\t\t};\n\t}\n\n\tvar docElem = document.documentElement;\n\n\tvar supportPicture = window.HTMLPictureElement;\n\n\tvar _addEventListener = 'addEventListener';\n\n\tvar _getAttribute = 'getAttribute';\n\n\t/**\n\t * Update to bind to window because 'this' becomes null during SSR\n\t * builds.\n\t */\n\tvar addEventListener = window[_addEventListener].bind(window);\n\n\tvar setTimeout = window.setTimeout;\n\n\tvar requestAnimationFrame = window.requestAnimationFrame || setTimeout;\n\n\tvar requestIdleCallback = window.requestIdleCallback;\n\n\tvar regPicture = /^picture$/i;\n\n\tvar loadEvents = ['load', 'error', 'lazyincluded', '_lazyloaded'];\n\n\tvar regClassCache = {};\n\n\tvar forEach = Array.prototype.forEach;\n\n\t/**\n\t * @param ele {Element}\n\t * @param cls {string}\n\t */\n\tvar hasClass = function(ele, cls) {\n\t\tif(!regClassCache[cls]){\n\t\t\tregClassCache[cls] = new RegExp('(\\\\s|^)'+cls+'(\\\\s|$)');\n\t\t}\n\t\treturn regClassCache[cls].test(ele[_getAttribute]('class') || '') && regClassCache[cls];\n\t};\n\n\t/**\n\t * @param ele {Element}\n\t * @param cls {string}\n\t */\n\tvar addClass = function(ele, cls) {\n\t\tif (!hasClass(ele, cls)){\n\t\t\tele.setAttribute('class', (ele[_getAttribute]('class') || '').trim() + ' ' + cls);\n\t\t}\n\t};\n\n\t/**\n\t * @param ele {Element}\n\t * @param cls {string}\n\t */\n\tvar removeClass = function(ele, cls) {\n\t\tvar reg;\n\t\tif ((reg = hasClass(ele,cls))) {\n\t\t\tele.setAttribute('class', (ele[_getAttribute]('class') || '').replace(reg, ' '));\n\t\t}\n\t};\n\n\tvar addRemoveLoadEvents = function(dom, fn, add){\n\t\tvar action = add ? _addEventListener : 'removeEventListener';\n\t\tif(add){\n\t\t\taddRemoveLoadEvents(dom, fn);\n\t\t}\n\t\tloadEvents.forEach(function(evt){\n\t\t\tdom[action](evt, fn);\n\t\t});\n\t};\n\n\t/**\n\t * @param elem { Element }\n\t * @param name { string }\n\t * @param detail { any }\n\t * @param noBubbles { boolean }\n\t * @param noCancelable { boolean }\n\t * @returns { CustomEvent }\n\t */\n\tvar triggerEvent = function(elem, name, detail, noBubbles, noCancelable){\n\t\tvar event = document.createEvent('Event');\n\n\t\tif(!detail){\n\t\t\tdetail = {};\n\t\t}\n\n\t\tdetail.instance = lazysizes;\n\n\t\tevent.initEvent(name, !noBubbles, !noCancelable);\n\n\t\tevent.detail = detail;\n\n\t\telem.dispatchEvent(event);\n\t\treturn event;\n\t};\n\n\tvar updatePolyfill = function (el, full){\n\t\tvar polyfill;\n\t\tif( !supportPicture && ( polyfill = (window.picturefill || lazySizesCfg.pf) ) ){\n\t\t\tif(full && full.src && !el[_getAttribute]('srcset')){\n\t\t\t\tel.setAttribute('srcset', full.src);\n\t\t\t}\n\t\t\tpolyfill({reevaluate: true, elements: [el]});\n\t\t} else if(full && full.src){\n\t\t\tel.src = full.src;\n\t\t}\n\t};\n\n\tvar getCSS = function (elem, style){\n\t\treturn (getComputedStyle(elem, null) || {})[style];\n\t};\n\n\t/**\n\t *\n\t * @param elem { Element }\n\t * @param parent { Element }\n\t * @param [width] {number}\n\t * @returns {number}\n\t */\n\tvar getWidth = function(elem, parent, width){\n\t\twidth = width || elem.offsetWidth;\n\n\t\twhile(width < lazySizesCfg.minSize && parent && !elem._lazysizesWidth){\n\t\t\twidth = parent.offsetWidth;\n\t\t\tparent = parent.parentNode;\n\t\t}\n\n\t\treturn width;\n\t};\n\n\tvar rAF = (function(){\n\t\tvar running, waiting;\n\t\tvar firstFns = [];\n\t\tvar secondFns = [];\n\t\tvar fns = firstFns;\n\n\t\tvar run = function(){\n\t\t\tvar runFns = fns;\n\n\t\t\tfns = firstFns.length ? secondFns : firstFns;\n\n\t\t\trunning = true;\n\t\t\twaiting = false;\n\n\t\t\twhile(runFns.length){\n\t\t\t\trunFns.shift()();\n\t\t\t}\n\n\t\t\trunning = false;\n\t\t};\n\n\t\tvar rafBatch = function(fn, queue){\n\t\t\tif(running && !queue){\n\t\t\t\tfn.apply(this, arguments);\n\t\t\t} else {\n\t\t\t\tfns.push(fn);\n\n\t\t\t\tif(!waiting){\n\t\t\t\t\twaiting = true;\n\t\t\t\t\t(document.hidden ? setTimeout : requestAnimationFrame)(run);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\trafBatch._lsFlush = run;\n\n\t\treturn rafBatch;\n\t})();\n\n\tvar rAFIt = function(fn, simple){\n\t\treturn simple ?\n\t\t\tfunction() {\n\t\t\t\trAF(fn);\n\t\t\t} :\n\t\t\tfunction(){\n\t\t\t\tvar that = this;\n\t\t\t\tvar args = arguments;\n\t\t\t\trAF(function(){\n\t\t\t\t\tfn.apply(that, args);\n\t\t\t\t});\n\t\t\t}\n\t\t;\n\t};\n\n\tvar throttle = function(fn){\n\t\tvar running;\n\t\tvar lastTime = 0;\n\t\tvar gDelay = lazySizesCfg.throttleDelay;\n\t\tvar rICTimeout = lazySizesCfg.ricTimeout;\n\t\tvar run = function(){\n\t\t\trunning = false;\n\t\t\tlastTime = Date.now();\n\t\t\tfn();\n\t\t};\n\t\tvar idleCallback = requestIdleCallback && rICTimeout > 49 ?\n\t\t\tfunction(){\n\t\t\t\trequestIdleCallback(run, {timeout: rICTimeout});\n\n\t\t\t\tif(rICTimeout !== lazySizesCfg.ricTimeout){\n\t\t\t\t\trICTimeout = lazySizesCfg.ricTimeout;\n\t\t\t\t}\n\t\t\t} :\n\t\t\trAFIt(function(){\n\t\t\t\tsetTimeout(run);\n\t\t\t}, true)\n\t\t;\n\n\t\treturn function(isPriority){\n\t\t\tvar delay;\n\n\t\t\tif((isPriority = isPriority === true)){\n\t\t\t\trICTimeout = 33;\n\t\t\t}\n\n\t\t\tif(running){\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\trunning = true;\n\n\t\t\tdelay = gDelay - (Date.now() - lastTime);\n\n\t\t\tif(delay < 0){\n\t\t\t\tdelay = 0;\n\t\t\t}\n\n\t\t\tif(isPriority || delay < 9){\n\t\t\t\tidleCallback();\n\t\t\t} else {\n\t\t\t\tsetTimeout(idleCallback, delay);\n\t\t\t}\n\t\t};\n\t};\n\n\t//based on http://modernjavascript.blogspot.de/2013/08/building-better-debounce.html\n\tvar debounce = function(func) {\n\t\tvar timeout, timestamp;\n\t\tvar wait = 99;\n\t\tvar run = function(){\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tvar later = function() {\n\t\t\tvar last = Date.now() - timestamp;\n\n\t\t\tif (last < wait) {\n\t\t\t\tsetTimeout(later, wait - last);\n\t\t\t} else {\n\t\t\t\t(requestIdleCallback || run)(run);\n\t\t\t}\n\t\t};\n\n\t\treturn function() {\n\t\t\ttimestamp = Date.now();\n\n\t\t\tif (!timeout) {\n\t\t\t\ttimeout = setTimeout(later, wait);\n\t\t\t}\n\t\t};\n\t};\n\n\tvar loader = (function(){\n\t\tvar preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;\n\n\t\tvar eLvW, elvH, eLtop, eLleft, eLright, eLbottom, isBodyHidden;\n\n\t\tvar regImg = /^img$/i;\n\t\tvar regIframe = /^iframe$/i;\n\n\t\tvar supportScroll = ('onscroll' in window) && !(/(gle|ing)bot/.test(navigator.userAgent));\n\n\t\tvar shrinkExpand = 0;\n\t\tvar currentExpand = 0;\n\n\t\tvar isLoading = 0;\n\t\tvar lowRuns = -1;\n\n\t\tvar resetPreloading = function(e){\n\t\t\tisLoading--;\n\t\t\tif(!e || isLoading < 0 || !e.target){\n\t\t\t\tisLoading = 0;\n\t\t\t}\n\t\t};\n\n\t\tvar isVisible = function (elem) {\n\t\t\tif (isBodyHidden == null) {\n\t\t\t\tisBodyHidden = getCSS(document.body, 'visibility') == 'hidden';\n\t\t\t}\n\n\t\t\treturn isBodyHidden || !(getCSS(elem.parentNode, 'visibility') == 'hidden' && getCSS(elem, 'visibility') == 'hidden');\n\t\t};\n\n\t\tvar isNestedVisible = function(elem, elemExpand){\n\t\t\tvar outerRect;\n\t\t\tvar parent = elem;\n\t\t\tvar visible = isVisible(elem);\n\n\t\t\teLtop -= elemExpand;\n\t\t\teLbottom += elemExpand;\n\t\t\teLleft -= elemExpand;\n\t\t\teLright += elemExpand;\n\n\t\t\twhile(visible && (parent = parent.offsetParent) && parent != document.body && parent != docElem){\n\t\t\t\tvisible = ((getCSS(parent, 'opacity') || 1) > 0);\n\n\t\t\t\tif(visible && getCSS(parent, 'overflow') != 'visible'){\n\t\t\t\t\touterRect = parent.getBoundingClientRect();\n\t\t\t\t\tvisible = eLright > outerRect.left &&\n\t\t\t\t\t\teLleft < outerRect.right &&\n\t\t\t\t\t\teLbottom > outerRect.top - 1 &&\n\t\t\t\t\t\teLtop < outerRect.bottom + 1\n\t\t\t\t\t;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn visible;\n\t\t};\n\n\t\tvar checkElements = function() {\n\t\t\tvar eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal,\n\t\t\t\tbeforeExpandVal, defaultExpand, preloadExpand, hFac;\n\t\t\tvar lazyloadElems = lazysizes.elements;\n\n\t\t\tif((loadMode = lazySizesCfg.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){\n\n\t\t\t\ti = 0;\n\n\t\t\t\tlowRuns++;\n\n\t\t\t\tfor(; i < eLlen; i++){\n\n\t\t\t\t\tif(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}\n\n\t\t\t\t\tif(!supportScroll || (lazysizes.prematureUnveil && lazysizes.prematureUnveil(lazyloadElems[i]))){unveilElement(lazyloadElems[i]);continue;}\n\n\t\t\t\t\tif(!(elemExpandVal = lazyloadElems[i][_getAttribute]('data-expand')) || !(elemExpand = elemExpandVal * 1)){\n\t\t\t\t\t\telemExpand = currentExpand;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!defaultExpand) {\n\t\t\t\t\t\tdefaultExpand = (!lazySizesCfg.expand || lazySizesCfg.expand < 1) ?\n\t\t\t\t\t\t\tdocElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370 :\n\t\t\t\t\t\t\tlazySizesCfg.expand;\n\n\t\t\t\t\t\tlazysizes._defEx = defaultExpand;\n\n\t\t\t\t\t\tpreloadExpand = defaultExpand * lazySizesCfg.expFactor;\n\t\t\t\t\t\thFac = lazySizesCfg.hFac;\n\t\t\t\t\t\tisBodyHidden = null;\n\n\t\t\t\t\t\tif(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden){\n\t\t\t\t\t\t\tcurrentExpand = preloadExpand;\n\t\t\t\t\t\t\tlowRuns = 0;\n\t\t\t\t\t\t} else if(loadMode > 1 && lowRuns > 1 && isLoading < 6){\n\t\t\t\t\t\t\tcurrentExpand = defaultExpand;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcurrentExpand = shrinkExpand;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(beforeExpandVal !== elemExpand){\n\t\t\t\t\t\teLvW = innerWidth + (elemExpand * hFac);\n\t\t\t\t\t\telvH = innerHeight + elemExpand;\n\t\t\t\t\t\telemNegativeExpand = elemExpand * -1;\n\t\t\t\t\t\tbeforeExpandVal = elemExpand;\n\t\t\t\t\t}\n\n\t\t\t\t\trect = lazyloadElems[i].getBoundingClientRect();\n\n\t\t\t\t\tif ((eLbottom = rect.bottom) >= elemNegativeExpand &&\n\t\t\t\t\t\t(eLtop = rect.top) <= elvH &&\n\t\t\t\t\t\t(eLright = rect.right) >= elemNegativeExpand * hFac &&\n\t\t\t\t\t\t(eLleft = rect.left) <= eLvW &&\n\t\t\t\t\t\t(eLbottom || eLright || eLleft || eLtop) &&\n\t\t\t\t\t\t(lazySizesCfg.loadHidden || isVisible(lazyloadElems[i])) &&\n\t\t\t\t\t\t((isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4)) || isNestedVisible(lazyloadElems[i], elemExpand))){\n\t\t\t\t\t\tunveilElement(lazyloadElems[i]);\n\t\t\t\t\t\tloadedSomething = true;\n\t\t\t\t\t\tif(isLoading > 9){break;}\n\t\t\t\t\t} else if(!loadedSomething && isCompleted && !autoLoadElem &&\n\t\t\t\t\t\tisLoading < 4 && lowRuns < 4 && loadMode > 2 &&\n\t\t\t\t\t\t(preloadElems[0] || lazySizesCfg.preloadAfterLoad) &&\n\t\t\t\t\t\t(preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesCfg.sizesAttr) != 'auto')))){\n\t\t\t\t\t\tautoLoadElem = preloadElems[0] || lazyloadElems[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(autoLoadElem && !loadedSomething){\n\t\t\t\t\tunveilElement(autoLoadElem);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tvar throttledCheckElements = throttle(checkElements);\n\n\t\tvar switchLoadingClass = function(e){\n\t\t\tvar elem = e.target;\n\n\t\t\tif (elem._lazyCache) {\n\t\t\t\tdelete elem._lazyCache;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresetPreloading(e);\n\t\t\taddClass(elem, lazySizesCfg.loadedClass);\n\t\t\tremoveClass(elem, lazySizesCfg.loadingClass);\n\t\t\taddRemoveLoadEvents(elem, rafSwitchLoadingClass);\n\t\t\ttriggerEvent(elem, 'lazyloaded');\n\t\t};\n\t\tvar rafedSwitchLoadingClass = rAFIt(switchLoadingClass);\n\t\tvar rafSwitchLoadingClass = function(e){\n\t\t\trafedSwitchLoadingClass({target: e.target});\n\t\t};\n\n\t\tvar changeIframeSrc = function(elem, src){\n\t\t\tvar loadMode = elem.getAttribute('data-load-mode') || lazySizesCfg.iframeLoadMode;\n\n\t\t\t// loadMode can be also a string!\n\t\t\tif (loadMode == 0) {\n\t\t\t\telem.contentWindow.location.replace(src);\n\t\t\t} else if (loadMode == 1) {\n\t\t\t\telem.src = src;\n\t\t\t}\n\t\t};\n\n\t\tvar handleSources = function(source){\n\t\t\tvar customMedia;\n\n\t\t\tvar sourceSrcset = source[_getAttribute](lazySizesCfg.srcsetAttr);\n\n\t\t\tif( (customMedia = lazySizesCfg.customMedia[source[_getAttribute]('data-media') || source[_getAttribute]('media')]) ){\n\t\t\t\tsource.setAttribute('media', customMedia);\n\t\t\t}\n\n\t\t\tif(sourceSrcset){\n\t\t\t\tsource.setAttribute('srcset', sourceSrcset);\n\t\t\t}\n\t\t};\n\n\t\tvar lazyUnveil = rAFIt(function (elem, detail, isAuto, sizes, isImg){\n\t\t\tvar src, srcset, parent, isPicture, event, firesLoad;\n\n\t\t\tif(!(event = triggerEvent(elem, 'lazybeforeunveil', detail)).defaultPrevented){\n\n\t\t\t\tif(sizes){\n\t\t\t\t\tif(isAuto){\n\t\t\t\t\t\taddClass(elem, lazySizesCfg.autosizesClass);\n\t\t\t\t\t} else {\n\t\t\t\t\t\telem.setAttribute('sizes', sizes);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsrcset = elem[_getAttribute](lazySizesCfg.srcsetAttr);\n\t\t\t\tsrc = elem[_getAttribute](lazySizesCfg.srcAttr);\n\n\t\t\t\tif(isImg) {\n\t\t\t\t\tparent = elem.parentNode;\n\t\t\t\t\tisPicture = parent && regPicture.test(parent.nodeName || '');\n\t\t\t\t}\n\n\t\t\t\tfiresLoad = detail.firesLoad || (('src' in elem) && (srcset || src || isPicture));\n\n\t\t\t\tevent = {target: elem};\n\n\t\t\t\taddClass(elem, lazySizesCfg.loadingClass);\n\n\t\t\t\tif(firesLoad){\n\t\t\t\t\tclearTimeout(resetPreloadingTimer);\n\t\t\t\t\tresetPreloadingTimer = setTimeout(resetPreloading, 2500);\n\t\t\t\t\taddRemoveLoadEvents(elem, rafSwitchLoadingClass, true);\n\t\t\t\t}\n\n\t\t\t\tif(isPicture){\n\t\t\t\t\tforEach.call(parent.getElementsByTagName('source'), handleSources);\n\t\t\t\t}\n\n\t\t\t\tif(srcset){\n\t\t\t\t\telem.setAttribute('srcset', srcset);\n\t\t\t\t} else if(src && !isPicture){\n\t\t\t\t\tif(regIframe.test(elem.nodeName)){\n\t\t\t\t\t\tchangeIframeSrc(elem, src);\n\t\t\t\t\t} else {\n\t\t\t\t\t\telem.src = src;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(isImg && (srcset || isPicture)){\n\t\t\t\t\tupdatePolyfill(elem, {src: src});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(elem._lazyRace){\n\t\t\t\tdelete elem._lazyRace;\n\t\t\t}\n\t\t\tremoveClass(elem, lazySizesCfg.lazyClass);\n\n\t\t\trAF(function(){\n\t\t\t\t// Part of this can be removed as soon as this fix is older: https://bugs.chromium.org/p/chromium/issues/detail?id=7731 (2015)\n\t\t\t\tvar isLoaded = elem.complete && elem.naturalWidth > 1;\n\n\t\t\t\tif( !firesLoad || isLoaded){\n\t\t\t\t\tif (isLoaded) {\n\t\t\t\t\t\taddClass(elem, lazySizesCfg.fastLoadedClass);\n\t\t\t\t\t}\n\t\t\t\t\tswitchLoadingClass(event);\n\t\t\t\t\telem._lazyCache = true;\n\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\tif ('_lazyCache' in elem) {\n\t\t\t\t\t\t\tdelete elem._lazyCache;\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 9);\n\t\t\t\t}\n\t\t\t\tif (elem.loading == 'lazy') {\n\t\t\t\t\tisLoading--;\n\t\t\t\t}\n\t\t\t}, true);\n\t\t});\n\n\t\t/**\n\t\t *\n\t\t * @param elem { Element }\n\t\t */\n\t\tvar unveilElement = function (elem){\n\t\t\tif (elem._lazyRace) {return;}\n\t\t\tvar detail;\n\n\t\t\tvar isImg = regImg.test(elem.nodeName);\n\n\t\t\t//allow using sizes=\"auto\", but don't use. it's invalid. Use data-sizes=\"auto\" or a valid value for sizes instead (i.e.: sizes=\"80vw\")\n\t\t\tvar sizes = isImg && (elem[_getAttribute](lazySizesCfg.sizesAttr) || elem[_getAttribute]('sizes'));\n\t\t\tvar isAuto = sizes == 'auto';\n\n\t\t\tif( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesCfg.errorClass) && hasClass(elem, lazySizesCfg.lazyClass)){return;}\n\n\t\t\tdetail = triggerEvent(elem, 'lazyunveilread').detail;\n\n\t\t\tif(isAuto){\n\t\t\t\t autoSizer.updateElem(elem, true, elem.offsetWidth);\n\t\t\t}\n\n\t\t\telem._lazyRace = true;\n\t\t\tisLoading++;\n\n\t\t\tlazyUnveil(elem, detail, isAuto, sizes, isImg);\n\t\t};\n\n\t\tvar afterScroll = debounce(function(){\n\t\t\tlazySizesCfg.loadMode = 3;\n\t\t\tthrottledCheckElements();\n\t\t});\n\n\t\tvar altLoadmodeScrollListner = function(){\n\t\t\tif(lazySizesCfg.loadMode == 3){\n\t\t\t\tlazySizesCfg.loadMode = 2;\n\t\t\t}\n\t\t\tafterScroll();\n\t\t};\n\n\t\tvar onload = function(){\n\t\t\tif(isCompleted){return;}\n\t\t\tif(Date.now() - started < 999){\n\t\t\t\tsetTimeout(onload, 999);\n\t\t\t\treturn;\n\t\t\t}\n\n\n\t\t\tisCompleted = true;\n\n\t\t\tlazySizesCfg.loadMode = 3;\n\n\t\t\tthrottledCheckElements();\n\n\t\t\taddEventListener('scroll', altLoadmodeScrollListner, true);\n\t\t};\n\n\t\treturn {\n\t\t\t_: function(){\n\t\t\t\tstarted = Date.now();\n\n\t\t\t\tlazysizes.elements = document.getElementsByClassName(lazySizesCfg.lazyClass);\n\t\t\t\tpreloadElems = document.getElementsByClassName(lazySizesCfg.lazyClass + ' ' + lazySizesCfg.preloadClass);\n\n\t\t\t\taddEventListener('scroll', throttledCheckElements, true);\n\n\t\t\t\taddEventListener('resize', throttledCheckElements, true);\n\n\t\t\t\taddEventListener('pageshow', function (e) {\n\t\t\t\t\tif (e.persisted) {\n\t\t\t\t\t\tvar loadingElements = document.querySelectorAll('.' + lazySizesCfg.loadingClass);\n\n\t\t\t\t\t\tif (loadingElements.length && loadingElements.forEach) {\n\t\t\t\t\t\t\trequestAnimationFrame(function () {\n\t\t\t\t\t\t\t\tloadingElements.forEach( function (img) {\n\t\t\t\t\t\t\t\t\tif (img.complete) {\n\t\t\t\t\t\t\t\t\t\tunveilElement(img);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tif(window.MutationObserver){\n\t\t\t\t\tnew MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );\n\t\t\t\t} else {\n\t\t\t\t\tdocElem[_addEventListener]('DOMNodeInserted', throttledCheckElements, true);\n\t\t\t\t\tdocElem[_addEventListener]('DOMAttrModified', throttledCheckElements, true);\n\t\t\t\t\tsetInterval(throttledCheckElements, 999);\n\t\t\t\t}\n\n\t\t\t\taddEventListener('hashchange', throttledCheckElements, true);\n\n\t\t\t\t//, 'fullscreenchange'\n\t\t\t\t['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend'].forEach(function(name){\n\t\t\t\t\tdocument[_addEventListener](name, throttledCheckElements, true);\n\t\t\t\t});\n\n\t\t\t\tif((/d$|^c/.test(document.readyState))){\n\t\t\t\t\tonload();\n\t\t\t\t} else {\n\t\t\t\t\taddEventListener('load', onload);\n\t\t\t\t\tdocument[_addEventListener]('DOMContentLoaded', throttledCheckElements);\n\t\t\t\t\tsetTimeout(onload, 20000);\n\t\t\t\t}\n\n\t\t\t\tif(lazysizes.elements.length){\n\t\t\t\t\tcheckElements();\n\t\t\t\t\trAF._lsFlush();\n\t\t\t\t} else {\n\t\t\t\t\tthrottledCheckElements();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcheckElems: throttledCheckElements,\n\t\t\tunveil: unveilElement,\n\t\t\t_aLSL: altLoadmodeScrollListner,\n\t\t};\n\t})();\n\n\n\tvar autoSizer = (function(){\n\t\tvar autosizesElems;\n\n\t\tvar sizeElement = rAFIt(function(elem, parent, event, width){\n\t\t\tvar sources, i, len;\n\t\t\telem._lazysizesWidth = width;\n\t\t\twidth += 'px';\n\n\t\t\telem.setAttribute('sizes', width);\n\n\t\t\tif(regPicture.test(parent.nodeName || '')){\n\t\t\t\tsources = parent.getElementsByTagName('source');\n\t\t\t\tfor(i = 0, len = sources.length; i < len; i++){\n\t\t\t\t\tsources[i].setAttribute('sizes', width);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(!event.detail.dataAttr){\n\t\t\t\tupdatePolyfill(elem, event.detail);\n\t\t\t}\n\t\t});\n\t\t/**\n\t\t *\n\t\t * @param elem {Element}\n\t\t * @param dataAttr\n\t\t * @param [width] { number }\n\t\t */\n\t\tvar getSizeElement = function (elem, dataAttr, width){\n\t\t\tvar event;\n\t\t\tvar parent = elem.parentNode;\n\n\t\t\tif(parent){\n\t\t\t\twidth = getWidth(elem, parent, width);\n\t\t\t\tevent = triggerEvent(elem, 'lazybeforesizes', {width: width, dataAttr: !!dataAttr});\n\n\t\t\t\tif(!event.defaultPrevented){\n\t\t\t\t\twidth = event.detail.width;\n\n\t\t\t\t\tif(width && width !== elem._lazysizesWidth){\n\t\t\t\t\t\tsizeElement(elem, parent, event, width);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tvar updateElementsSizes = function(){\n\t\t\tvar i;\n\t\t\tvar len = autosizesElems.length;\n\t\t\tif(len){\n\t\t\t\ti = 0;\n\n\t\t\t\tfor(; i < len; i++){\n\t\t\t\t\tgetSizeElement(autosizesElems[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tvar debouncedUpdateElementsSizes = debounce(updateElementsSizes);\n\n\t\treturn {\n\t\t\t_: function(){\n\t\t\t\tautosizesElems = document.getElementsByClassName(lazySizesCfg.autosizesClass);\n\t\t\t\taddEventListener('resize', debouncedUpdateElementsSizes);\n\t\t\t},\n\t\t\tcheckElems: debouncedUpdateElementsSizes,\n\t\t\tupdateElem: getSizeElement\n\t\t};\n\t})();\n\n\tvar init = function(){\n\t\tif(!init.i && document.getElementsByClassName){\n\t\t\tinit.i = true;\n\t\t\tautoSizer._();\n\t\t\tloader._();\n\t\t}\n\t};\n\n\tsetTimeout(function(){\n\t\tif(lazySizesCfg.init){\n\t\t\tinit();\n\t\t}\n\t});\n\n\tlazysizes = {\n\t\t/**\n\t\t * @type { LazySizesConfigPartial }\n\t\t */\n\t\tcfg: lazySizesCfg,\n\t\tautoSizer: autoSizer,\n\t\tloader: loader,\n\t\tinit: init,\n\t\tuP: updatePolyfill,\n\t\taC: addClass,\n\t\trC: removeClass,\n\t\thC: hasClass,\n\t\tfire: triggerEvent,\n\t\tgW: getWidth,\n\t\trAF: rAF,\n\t};\n\n\treturn lazysizes;\n}\n));\n", "up.macro('#query_diet', (element) => {\n\n element.removeAttribute('onclick')\n up.on(element, 'click', () => { element.remove() })\n\n})\n", "up.compiler('video', (element) => {\n\n element.addEventListener('play', () => {\n element.currentTime = 0\n }, { once: true })\n\n})\n", "up.compiler('[accept-on-change]', (element) => {\n return up.on('change', () => {\n up.layer.accept(element.value)\n })\n})\n", "up.compiler('[active-on-clicked]', function(element) {\n up.on(element, 'click', (evt) => {\n // in feature specs: spec is too fast and still shows Unpoly's .up-active class\n const classNames = element.getAttribute('class').replaceAll(' up-active', '').replaceAll(' ', '.')\n document.querySelectorAll(`.${classNames}`).forEach((sibling) => {\n sibling.classList.remove('-active')\n })\n element.classList.add('-active')\n })\n})\n", "up.compiler('[alert-message-on-click]', (element, { message }) => {\n element.addEventListener('click', () => {\n alert(message)\n })\n})\n", "let currentRelease\nlet lastNotified\n\nconst newReleaseMessage = `\n
\n

\n Es gibt \u00C4nderungen an der Radfahrausbildung-App.\n
\n Bitte lade bei n\u00E4chster Gelegenheit neu!\n

\n

\n Beachte: Du bleibst angemeldet und kannst sofort weitermachen.\n

\n

\n Wenn du nicht m\u00F6chtest, musst du nicht jetzt neu laden. Die Anwendung funktioniert dann aber vielleicht nicht richtig.\n

\n\n

\n \n \n

\n
\n`\n\nup.compiler('[app-status]', (element, { release, frequency }) => {\n\n currentRelease ??= release\n frequency ??= 30000\n\n const time = new Date().getTime()\n\n function recentlyNotified() {\n return lastNotified && (time - lastNotified) < frequency\n }\n\n function showReloadNotification() {\n up.layer.open({\n content: newReleaseMessage,\n size: 'auto',\n onAccepted: () => { location.reload() },\n })\n }\n\n if (currentRelease !== release && !recentlyNotified()) {\n showReloadNotification()\n lastNotified = time\n }\n\n})\n", "up.compiler('[code-search]', (element) => {\n\n const button = element.querySelector('button')\n const input = element.querySelector('input[type=\"text\"]')\n\n input.addEventListener('input', onInput)\n element.addEventListener('submit', onSubmit)\n\n function onInput() {\n enableOrDisable()\n }\n\n function onSubmit(event) {\n event.preventDefault()\n const value = getValue()\n\n if (value) {\n up.request(`/c/${getValue()}.json`).then(onSuccess).catch(onError)\n } else {\n input.focus()\n }\n }\n\n function onSuccess(response) {\n up.visit(response.json.url)\n input.value = ''\n }\n\n function onError(response) {\n alert(response.json.error || 'Hoppla, das hat nicht geklappt! Bitte versuche es sp\u00E4ter nochmal.')\n input.focus()\n }\n\n function enableOrDisable() {\n // If no value is entered, the submit button should appear disabled, but still be clickable.\n // When users click the \"disabled\" button, we focus the input instead.\n const disabled = !getValue()\n button.classList.toggle('disabled', disabled)\n button.classList.toggle('pe-auto', disabled)\n }\n\n function getValue() {\n return input.value.trim()\n }\n\n enableOrDisable()\n\n})\n", "up.compiler('[content-code-search]', (element) => {\n document.body.classList.add('-search-shown')\n\n return () => {\n document.body.classList.remove('-search-shown')\n }\n})\n", "up.compiler('.full-avatar', (element) => {\n\n const image = element.querySelector('img')\n let animating = false\n\n async function onClick() {\n if (animating) return\n\n animating = true\n const animations = [bounce, flip, wheelie]\n const animation = animations[Math.floor(Math.random() * animations.length)]\n\n await animation()\n image.style.removeProperty('transform')\n image.style.removeProperty('transform-origin')\n animating = false\n }\n\n async function bounce() {\n async function bounceBy(offset, duration) {\n if (!image.isConnected) return Promise.resolve()\n\n await up.animate(image, { transform: `translateY(-${offset}px)` }, { duration: duration / 2 })\n return up.animate(image, { transform: 'translateY(0)' }, { duration: duration / 2 })\n }\n\n await bounceBy(100, 240)\n await bounceBy(60, 120)\n await bounceBy(30, 60)\n return bounceBy(15, 30)\n }\n\n async function flip() {\n return up.animate(image, { transform: 'rotateY(-720deg)' }, { duration: 1080 })\n }\n\n async function wheelie() {\n async function turnBy(degrees, duration) {\n if (!image.isConnected) return Promise.resolve()\n\n await up.animate(image, { transform: `rotate(-${degrees}deg)` }, { duration: duration * 2 / 3 })\n return up.animate(image, { transform: 'rotate(0)' }, { duration: duration * 1 / 3 })\n }\n\n image.style.setProperty('transform-origin', 'left bottom')\n await turnBy(25, 360)\n return turnBy(5, 60)\n }\n\n element.addEventListener('click', onClick)\n\n})\n", "up.compiler('[full-screen-toggle]', (elem) => {\n function toggleFullscreen(evt) {\n const container = evt.target.closest('main.container')\n\n if (container.classList.contains('-fullscreen')) {\n exitFullScreen()\n container.classList.remove('-fullscreen')\n } else {\n enterFullScreen(container)\n container.classList.add('-fullscreen')\n }\n }\n\n up.on(elem, 'click', toggleFullscreen)\n up.on('fullscreenchange', closeFullscreenOnKeyEvent)\n up.on('webkitfullscreenchange', closeFullscreenOnKeyEvent)\n up.on('mozfullscreenchange', closeFullscreenOnKeyEvent)\n up.on('MSFullscreenChange', closeFullscreenOnKeyEvent)\n\n function closeFullscreenOnKeyEvent(evt) {\n if (!document.fullscreenElement && !document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement) {\n exitFullScreen()\n const container = evt.target.closest('main.container')\n container.classList.remove('-fullscreen')\n }\n }\n\n function exitFullScreen() {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n }\n }\n\n function enterFullScreen(elem) {\n if (elem.requestFullscreen) {\n elem.requestFullscreen()\n } else if (elem.mozRequestFullScreen) {\n elem.mozRequestFullScreen()\n } else if (elem.webkitRequestFullscreen) {\n elem.webkitRequestFullscreen()\n } else if (elem.msRequestFullscreen) {\n elem.msRequestFullscreen()\n }\n }\n})\n", "up.compiler('[go-back]', (element) => {\n element.addEventListener('click', () => history.back())\n})\n", "up.compiler('[image-in-lightbox]', (element, { url, showButton = true }) => {\n\n if (element.closest('.-draggable')) return\n\n let lightbox\n\n const container = up.element.affix(element.parentElement, '.lightbox-image-container')\n container.appendChild(element)\n\n if (showButton) {\n const button = up.element.createFromHTML(`\n \n `)\n container.appendChild(button)\n }\n\n function openLightbox() {\n lightbox ??= buildLightbox()\n up.element.setAttrs(lightbox, { open: true })\n }\n\n function closeLightbox() {\n up.element.setAttrs(lightbox, { open: false })\n }\n\n function destroyLightbox() {\n lightbox?.remove()\n }\n\n function buildLightbox() {\n lightbox = up.element.createFromHTML(`\n
\n
\n \n
\n
\n `)\n document.body.appendChild(lightbox)\n lightbox.addEventListener('click', closeLightbox)\n return lightbox\n }\n\n container.addEventListener('click', openLightbox)\n\n return destroyLightbox\n\n})\n", "// we allowlist some javascript: links and eval them ourselves, otherwise CSP will block execution\n\nup.compiler('a[href^=\"javascript:\"]', (element) => {\n element.addEventListener('click', (event) => {\n event.preventDefault()\n const javascriptCode = element.href.split(':')[1].trim()\n switch (javascriptCode) {\n case 'gaOptout()': {\n // Method is provided through Google Tag Manager\n window.gaOptout()\n break\n }\n }\n })\n})\n", "export class BitMatrix {\n public static createEmpty(width: number, height: number) {\n return new BitMatrix(new Uint8ClampedArray(width * height), width);\n }\n\n public width: number;\n public height: number;\n private data: Uint8ClampedArray;\n\n constructor(data: Uint8ClampedArray, width: number) {\n this.width = width;\n this.height = data.length / width;\n this.data = data;\n }\n\n public get(x: number, y: number): boolean {\n if (x < 0 || x >= this.width || y < 0 || y >= this.height) {\n return false;\n }\n return !!this.data[y * this.width + x];\n }\n\n public set(x: number, y: number, v: boolean) {\n this.data[y * this.width + x] = v ? 1 : 0;\n }\n\n public setRegion(left: number, top: number, width: number, height: number, v: boolean) {\n for (let y = top; y < top + height; y++) {\n for (let x = left; x < left + width; x++) {\n this.set(x, y, !!v);\n }\n }\n }\n}\n", "import {BitMatrix} from \"../BitMatrix\";\nimport {GreyscaleWeights} from \"../index\";\n\nconst REGION_SIZE = 8;\nconst MIN_DYNAMIC_RANGE = 24;\n\nfunction numBetween(value: number, min: number, max: number): number {\n return value < min ? min : value > max ? max : value;\n}\n\n// Like BitMatrix but accepts arbitry Uint8 values\nclass Matrix {\n private data: Uint8ClampedArray;\n private width: number;\n constructor(width: number, height: number, buffer?: Uint8ClampedArray) {\n this.width = width;\n const bufferSize = width * height;\n if (buffer && buffer.length !== bufferSize) {\n throw new Error(\"Wrong buffer size\");\n }\n this.data = buffer || new Uint8ClampedArray(bufferSize);\n }\n public get(x: number, y: number) {\n return this.data[y * this.width + x];\n }\n public set(x: number, y: number, value: number) {\n this.data[y * this.width + x] = value;\n }\n}\n\nexport function binarize(data: Uint8ClampedArray, width: number, height: number, returnInverted: boolean,\n greyscaleWeights: GreyscaleWeights, canOverwriteImage: boolean) {\n const pixelCount = width * height;\n if (data.length !== pixelCount * 4) {\n throw new Error(\"Malformed data passed to binarizer.\");\n }\n // assign the greyscale and binary image within the rgba buffer as the rgba image will not be needed after conversion\n let bufferOffset = 0;\n // Convert image to greyscale\n let greyscaleBuffer: Uint8ClampedArray;\n if (canOverwriteImage) {\n greyscaleBuffer = new Uint8ClampedArray(data.buffer, bufferOffset, pixelCount);\n bufferOffset += pixelCount;\n }\n const greyscalePixels = new Matrix(width, height, greyscaleBuffer);\n if (greyscaleWeights.useIntegerApproximation) {\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const pixelPosition = (y * width + x) * 4;\n const r = data[pixelPosition];\n const g = data[pixelPosition + 1];\n const b = data[pixelPosition + 2];\n greyscalePixels.set(x, y,\n // tslint:disable-next-line no-bitwise\n (greyscaleWeights.red * r + greyscaleWeights.green * g + greyscaleWeights.blue * b + 128) >> 8);\n }\n }\n } else {\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const pixelPosition = (y * width + x) * 4;\n const r = data[pixelPosition];\n const g = data[pixelPosition + 1];\n const b = data[pixelPosition + 2];\n greyscalePixels.set(x, y,\n greyscaleWeights.red * r + greyscaleWeights.green * g + greyscaleWeights.blue * b);\n }\n }\n }\n const horizontalRegionCount = Math.ceil(width / REGION_SIZE);\n const verticalRegionCount = Math.ceil(height / REGION_SIZE);\n const blackPointsCount = horizontalRegionCount * verticalRegionCount;\n\n let blackPointsBuffer: Uint8ClampedArray;\n if (canOverwriteImage) {\n blackPointsBuffer = new Uint8ClampedArray(data.buffer, bufferOffset, blackPointsCount);\n bufferOffset += blackPointsCount;\n }\n const blackPoints = new Matrix(horizontalRegionCount, verticalRegionCount, blackPointsBuffer);\n for (let verticalRegion = 0; verticalRegion < verticalRegionCount; verticalRegion++) {\n for (let hortizontalRegion = 0; hortizontalRegion < horizontalRegionCount; hortizontalRegion++) {\n let min = Infinity;\n let max = 0;\n for (let y = 0; y < REGION_SIZE; y++) {\n for (let x = 0; x < REGION_SIZE; x++) {\n const pixelLumosity =\n greyscalePixels.get(hortizontalRegion * REGION_SIZE + x, verticalRegion * REGION_SIZE + y);\n min = Math.min(min, pixelLumosity);\n max = Math.max(max, pixelLumosity);\n }\n }\n // We could also compute the real average of all pixels but following the assumption that the qr code consists\n // of bright and dark pixels and essentially not much in between, by (min + max)/2 we make the cut really between\n // those two classes. If using the average over all pixel in a block of mostly bright pixels and few dark pixels,\n // the avg would tend to the bright side and darker bright pixels could be interpreted as dark.\n let average = (min + max) / 2;\n // Small bias towards black by moving the threshold up. We do this, as in the finder patterns white holes tend\n // to appear which makes them undetectable.\n const blackBias = 1.11;\n average = Math.min(255, average * blackBias);\n if (max - min <= MIN_DYNAMIC_RANGE) {\n // If variation within the block is low, assume this is a block with only light or only\n // dark pixels. In that case we do not want to use the average, as it would divide this\n // low contrast area into black and white pixels, essentially creating data out of noise.\n //\n // Default the blackpoint for these blocks to be half the min - effectively white them out\n average = min / 2;\n\n if (verticalRegion > 0 && hortizontalRegion > 0) {\n // Correct the \"white background\" assumption for blocks that have neighbors by comparing\n // the pixels in this block to the previously calculated black points. This is based on\n // the fact that dark barcode symbology is always surrounded by some amount of light\n // background for which reasonable black point estimates were made. The bp estimated at\n // the boundaries is used for the interior.\n\n // The (min < bp) is arbitrary but works better than other heuristics that were tried.\n const averageNeighborBlackPoint = (\n blackPoints.get(hortizontalRegion, verticalRegion - 1) +\n (2 * blackPoints.get(hortizontalRegion - 1, verticalRegion)) +\n blackPoints.get(hortizontalRegion - 1, verticalRegion - 1)\n ) / 4;\n if (min < averageNeighborBlackPoint) {\n average = averageNeighborBlackPoint; // no need to apply black bias as already applied to neighbors\n }\n }\n }\n blackPoints.set(hortizontalRegion, verticalRegion, average);\n }\n }\n\n let binarized: BitMatrix;\n if (canOverwriteImage) {\n const binarizedBuffer = new Uint8ClampedArray(data.buffer, bufferOffset, pixelCount);\n bufferOffset += pixelCount;\n binarized = new BitMatrix(binarizedBuffer, width);\n } else {\n binarized = BitMatrix.createEmpty(width, height);\n }\n\n let inverted: BitMatrix = null;\n if (returnInverted) {\n if (canOverwriteImage) {\n const invertedBuffer = new Uint8ClampedArray(data.buffer, bufferOffset, pixelCount);\n inverted = new BitMatrix(invertedBuffer, width);\n } else {\n inverted = BitMatrix.createEmpty(width, height);\n }\n }\n\n for (let verticalRegion = 0; verticalRegion < verticalRegionCount; verticalRegion++) {\n for (let hortizontalRegion = 0; hortizontalRegion < horizontalRegionCount; hortizontalRegion++) {\n const left = numBetween(hortizontalRegion, 2, horizontalRegionCount - 3);\n const top = numBetween(verticalRegion, 2, verticalRegionCount - 3);\n let sum = 0;\n for (let xRegion = -2; xRegion <= 2; xRegion++) {\n for (let yRegion = -2; yRegion <= 2; yRegion++) {\n sum += blackPoints.get(left + xRegion, top + yRegion);\n }\n }\n const threshold = sum / 25;\n for (let xRegion = 0; xRegion < REGION_SIZE; xRegion++) {\n for (let yRegion = 0; yRegion < REGION_SIZE; yRegion++) {\n const x = hortizontalRegion * REGION_SIZE + xRegion;\n const y = verticalRegion * REGION_SIZE + yRegion;\n const lum = greyscalePixels.get(x, y);\n binarized.set(x, y, lum <= threshold);\n if (returnInverted) {\n inverted.set(x, y, !(lum <= threshold));\n }\n }\n }\n }\n }\n if (returnInverted) {\n return { binarized, inverted };\n }\n return { binarized };\n}\n", "// tslint:disable:no-bitwise\n\nexport class BitStream {\n private bytes: Uint8ClampedArray;\n private byteOffset: number = 0;\n private bitOffset: number = 0;\n\n constructor(bytes: Uint8ClampedArray) {\n this.bytes = bytes;\n }\n\n public readBits(numBits: number): number {\n if (numBits < 1 || numBits > 32 || numBits > this.available()) {\n throw new Error(\"Cannot read \" + numBits.toString() + \" bits\");\n }\n\n let result = 0;\n // First, read remainder from current byte\n if (this.bitOffset > 0) {\n const bitsLeft = 8 - this.bitOffset;\n const toRead = numBits < bitsLeft ? numBits : bitsLeft;\n const bitsToNotRead = bitsLeft - toRead;\n const mask = (0xFF >> (8 - toRead)) << bitsToNotRead;\n result = (this.bytes[this.byteOffset] & mask) >> bitsToNotRead;\n numBits -= toRead;\n this.bitOffset += toRead;\n if (this.bitOffset === 8) {\n this.bitOffset = 0;\n this.byteOffset++;\n }\n }\n\n // Next read whole bytes\n if (numBits > 0) {\n while (numBits >= 8) {\n result = (result << 8) | (this.bytes[this.byteOffset] & 0xFF);\n this.byteOffset++;\n numBits -= 8;\n }\n\n // Finally read a partial byte\n if (numBits > 0) {\n const bitsToNotRead = 8 - numBits;\n const mask = (0xFF >> bitsToNotRead) << bitsToNotRead;\n result = (result << numBits) | ((this.bytes[this.byteOffset] & mask) >> bitsToNotRead);\n this.bitOffset += numBits;\n }\n }\n return result;\n }\n\n public available(): number {\n return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset;\n }\n}\n", "// tslint:disable:no-bitwise\nimport { BitStream } from \"./BitStream\";\n\nexport interface Chunk {\n type: Mode;\n text: string;\n}\n\nexport interface ByteChunk {\n type: Mode.Byte | Mode.Kanji;\n bytes: number[];\n}\n\nexport interface ECIChunk {\n type: Mode.ECI;\n assignmentNumber: number;\n}\n\nexport interface StructuredAppend {\n type: Mode.StructuredAppend;\n currentSequence: number;\n totalSequence: number;\n parity: number;\n}\n\nexport type Chunks = Array;\n\nexport interface DecodedQR {\n text: string;\n bytes: number[];\n chunks: Chunks;\n version: number;\n}\n\nexport enum Mode {\n Numeric = \"numeric\",\n Alphanumeric = \"alphanumeric\",\n Byte = \"byte\",\n Kanji = \"kanji\",\n ECI = \"eci\",\n StructuredAppend = \"structuredappend\",\n}\n\nenum ModeByte {\n Terminator = 0x0,\n Numeric = 0x1,\n Alphanumeric = 0x2,\n Byte = 0x4,\n Kanji = 0x8,\n ECI = 0x7,\n StructuredAppend = 0x3,\n // FNC1FirstPosition = 0x5,\n // FNC1SecondPosition = 0x9,\n}\n\nfunction decodeNumeric(stream: BitStream, size: number) {\n const bytes: number[] = [];\n let text = \"\";\n\n const characterCountSize = [10, 12, 14][size];\n let length = stream.readBits(characterCountSize);\n // Read digits in groups of 3\n while (length >= 3) {\n const num = stream.readBits(10);\n if (num >= 1000) {\n throw new Error(\"Invalid numeric value above 999\");\n }\n\n const a = Math.floor(num / 100);\n const b = Math.floor(num / 10) % 10;\n const c = num % 10;\n\n bytes.push(48 + a, 48 + b, 48 + c);\n text += a.toString() + b.toString() + c.toString();\n length -= 3;\n }\n\n // If the number of digits aren't a multiple of 3, the remaining digits are special cased.\n if (length === 2) {\n const num = stream.readBits(7);\n if (num >= 100) {\n throw new Error(\"Invalid numeric value above 99\");\n }\n\n const a = Math.floor(num / 10);\n const b = num % 10;\n\n bytes.push(48 + a, 48 + b);\n text += a.toString() + b.toString();\n } else if (length === 1) {\n const num = stream.readBits(4);\n if (num >= 10) {\n throw new Error(\"Invalid numeric value above 9\");\n }\n\n bytes.push(48 + num);\n text += num.toString();\n }\n\n return { bytes, text };\n}\n\nconst AlphanumericCharacterCodes = [\n \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\",\n \"9\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\",\n \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\",\n \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\",\n \" \", \"$\", \"%\", \"*\", \"+\", \"-\", \".\", \"/\", \":\",\n];\n\nfunction decodeAlphanumeric(stream: BitStream, size: number) {\n const bytes: number[] = [];\n let text = \"\";\n\n const characterCountSize = [9, 11, 13][size];\n let length = stream.readBits(characterCountSize);\n while (length >= 2) {\n const v = stream.readBits(11);\n\n const a = Math.floor(v / 45);\n const b = v % 45;\n\n bytes.push(AlphanumericCharacterCodes[a].charCodeAt(0), AlphanumericCharacterCodes[b].charCodeAt(0));\n text += AlphanumericCharacterCodes[a] + AlphanumericCharacterCodes[b];\n length -= 2;\n }\n\n if (length === 1) {\n const a = stream.readBits(6);\n bytes.push(AlphanumericCharacterCodes[a].charCodeAt(0));\n text += AlphanumericCharacterCodes[a];\n }\n\n return { bytes, text };\n}\n\nfunction decodeByte(stream: BitStream, size: number) {\n const bytes: number[] = [];\n let text = \"\";\n\n const characterCountSize = [8, 16, 16][size];\n const length = stream.readBits(characterCountSize);\n for (let i = 0; i < length; i++) {\n const b = stream.readBits(8);\n bytes.push(b);\n }\n try {\n text += decodeURIComponent(bytes.map(b => `%${(\"0\" + b.toString(16)).substr(-2)}`).join(\"\"));\n } catch {\n // failed to decode\n }\n\n return { bytes, text };\n}\n\nfunction decodeKanji(stream: BitStream, size: number) {\n const bytes: number[] = [];\n\n const characterCountSize = [8, 10, 12][size];\n const length = stream.readBits(characterCountSize);\n for (let i = 0; i < length; i++) {\n const k = stream.readBits(13);\n\n let c = (Math.floor(k / 0xC0) << 8) | (k % 0xC0);\n if (c < 0x1F00) {\n c += 0x8140;\n } else {\n c += 0xC140;\n }\n\n bytes.push(c >> 8, c & 0xFF);\n }\n\n const text = new TextDecoder(\"shift-jis\").decode(Uint8Array.from(bytes));\n return { bytes, text };\n}\n\nexport function decode(data: Uint8ClampedArray, version: number): DecodedQR {\n const stream = new BitStream(data);\n\n // There are 3 'sizes' based on the version. 1-9 is small (0), 10-26 is medium (1) and 27-40 is large (2).\n const size = version <= 9 ? 0 : version <= 26 ? 1 : 2;\n\n const result: DecodedQR = {\n text: \"\",\n bytes: [],\n chunks: [],\n version,\n };\n\n while (stream.available() >= 4) {\n const mode = stream.readBits(4);\n if (mode === ModeByte.Terminator) {\n return result;\n } else if (mode === ModeByte.ECI) {\n if (stream.readBits(1) === 0) {\n result.chunks.push({\n type: Mode.ECI,\n assignmentNumber: stream.readBits(7),\n });\n } else if (stream.readBits(1) === 0) {\n result.chunks.push({\n type: Mode.ECI,\n assignmentNumber: stream.readBits(14),\n });\n } else if (stream.readBits(1) === 0) {\n result.chunks.push({\n type: Mode.ECI,\n assignmentNumber: stream.readBits(21),\n });\n } else {\n // ECI data seems corrupted\n result.chunks.push({\n type: Mode.ECI,\n assignmentNumber: -1,\n });\n }\n } else if (mode === ModeByte.Numeric) {\n const numericResult = decodeNumeric(stream, size);\n result.text += numericResult.text;\n result.bytes.push(...numericResult.bytes);\n result.chunks.push({\n type: Mode.Numeric,\n text: numericResult.text,\n });\n } else if (mode === ModeByte.Alphanumeric) {\n const alphanumericResult = decodeAlphanumeric(stream, size);\n result.text += alphanumericResult.text;\n result.bytes.push(...alphanumericResult.bytes);\n result.chunks.push({\n type: Mode.Alphanumeric,\n text: alphanumericResult.text,\n });\n } else if (mode === ModeByte.Byte) {\n const byteResult = decodeByte(stream, size);\n result.text += byteResult.text;\n result.bytes.push(...byteResult.bytes);\n result.chunks.push({\n type: Mode.Byte,\n bytes: byteResult.bytes,\n text: byteResult.text,\n });\n } else if (mode === ModeByte.Kanji) {\n const kanjiResult = decodeKanji(stream, size);\n result.text += kanjiResult.text;\n result.bytes.push(...kanjiResult.bytes);\n result.chunks.push({\n type: Mode.Kanji,\n bytes: kanjiResult.bytes,\n text: kanjiResult.text,\n });\n } else if (mode === ModeByte.StructuredAppend) {\n result.chunks.push({\n type: Mode.StructuredAppend,\n currentSequence: stream.readBits(4),\n totalSequence: stream.readBits(4),\n parity: stream.readBits(8),\n });\n }\n }\n\n // If there is no data left, or the remaining bits are all 0, then that counts as a termination marker\n if (stream.available() === 0 || stream.readBits(stream.available()) === 0) {\n return result;\n }\n}\n", "import GenericGF, { addOrSubtractGF } from \"./GenericGF\";\n\nexport default class GenericGFPoly {\n private field: GenericGF;\n private coefficients: Uint8ClampedArray;\n\n constructor(field: GenericGF, coefficients: Uint8ClampedArray) {\n if (coefficients.length === 0) {\n throw new Error(\"No coefficients.\");\n }\n this.field = field;\n const coefficientsLength = coefficients.length;\n if (coefficientsLength > 1 && coefficients[0] === 0) {\n // Leading term must be non-zero for anything except the constant polynomial \"0\"\n let firstNonZero = 1;\n while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) {\n firstNonZero++;\n }\n if (firstNonZero === coefficientsLength) {\n this.coefficients = field.zero.coefficients;\n } else {\n this.coefficients = new Uint8ClampedArray(coefficientsLength - firstNonZero);\n for (let i = 0; i < this.coefficients.length; i++) {\n this.coefficients[i] = coefficients[firstNonZero + i];\n }\n }\n } else {\n this.coefficients = coefficients;\n }\n }\n\n public degree() {\n return this.coefficients.length - 1;\n }\n\n public isZero() {\n return this.coefficients[0] === 0;\n }\n\n public getCoefficient(degree: number) {\n return this.coefficients[this.coefficients.length - 1 - degree];\n }\n\n public addOrSubtract(other: GenericGFPoly) {\n if (this.isZero()) {\n return other;\n }\n if (other.isZero()) {\n return this;\n }\n\n let smallerCoefficients = this.coefficients;\n let largerCoefficients = other.coefficients;\n if (smallerCoefficients.length > largerCoefficients.length) {\n [smallerCoefficients, largerCoefficients] = [largerCoefficients, smallerCoefficients];\n }\n const sumDiff = new Uint8ClampedArray(largerCoefficients.length);\n const lengthDiff = largerCoefficients.length - smallerCoefficients.length;\n for (let i = 0; i < lengthDiff; i++) {\n sumDiff[i] = largerCoefficients[i];\n }\n\n for (let i = lengthDiff; i < largerCoefficients.length; i++) {\n sumDiff[i] = addOrSubtractGF(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);\n }\n\n return new GenericGFPoly(this.field, sumDiff);\n }\n\n public multiply(scalar: number) {\n if (scalar === 0) {\n return this.field.zero;\n }\n if (scalar === 1) {\n return this;\n }\n const size = this.coefficients.length;\n const product = new Uint8ClampedArray(size);\n for (let i = 0; i < size; i++) {\n product[i] = this.field.multiply(this.coefficients[i], scalar);\n }\n\n return new GenericGFPoly(this.field, product);\n }\n\n public multiplyPoly(other: GenericGFPoly): GenericGFPoly {\n if (this.isZero() || other.isZero()) {\n return this.field.zero;\n }\n const aCoefficients = this.coefficients;\n const aLength = aCoefficients.length;\n const bCoefficients = other.coefficients;\n const bLength = bCoefficients.length;\n const product = new Uint8ClampedArray(aLength + bLength - 1);\n for (let i = 0; i < aLength; i++) {\n const aCoeff = aCoefficients[i];\n for (let j = 0; j < bLength; j++) {\n product[i + j] = addOrSubtractGF(product[i + j],\n this.field.multiply(aCoeff, bCoefficients[j]));\n }\n }\n return new GenericGFPoly(this.field, product);\n }\n\n public multiplyByMonomial(degree: number, coefficient: number) {\n if (degree < 0) {\n throw new Error(\"Invalid degree less than 0\");\n }\n if (coefficient === 0) {\n return this.field.zero;\n }\n const size = this.coefficients.length;\n const product = new Uint8ClampedArray(size + degree);\n for (let i = 0; i < size; i++) {\n product[i] = this.field.multiply(this.coefficients[i], coefficient);\n }\n return new GenericGFPoly(this.field, product);\n }\n\n public evaluateAt(a: number) {\n let result = 0;\n if (a === 0) {\n // Just return the x^0 coefficient\n return this.getCoefficient(0);\n }\n const size = this.coefficients.length;\n if (a === 1) {\n // Just the sum of the coefficients\n this.coefficients.forEach((coefficient) => {\n result = addOrSubtractGF(result, coefficient);\n });\n return result;\n }\n result = this.coefficients[0];\n for (let i = 1; i < size; i++) {\n result = addOrSubtractGF(this.field.multiply(a, result), this.coefficients[i]);\n }\n return result;\n }\n}\n", "import GenericGFPoly from \"./GenericGFPoly\";\n\nexport function addOrSubtractGF(a: number, b: number) {\n return a ^ b; // tslint:disable-line:no-bitwise\n}\n\nexport default class GenericGF {\n public primitive: number;\n public size: number;\n public generatorBase: number;\n public zero: GenericGFPoly;\n public one: GenericGFPoly;\n\n private expTable: number[];\n private logTable: number[];\n\n constructor(primitive: number, size: number, genBase: number) {\n this.primitive = primitive;\n this.size = size;\n this.generatorBase = genBase;\n this.expTable = new Array(this.size);\n this.logTable = new Array(this.size);\n\n let x = 1;\n for (let i = 0; i < this.size; i++) {\n this.expTable[i] = x;\n x = x * 2;\n if (x >= this.size) {\n x = (x ^ this.primitive) & (this.size - 1); // tslint:disable-line:no-bitwise\n }\n }\n\n for (let i = 0; i < this.size - 1; i++) {\n this.logTable[this.expTable[i]] = i;\n }\n this.zero = new GenericGFPoly(this, Uint8ClampedArray.from([0]));\n this.one = new GenericGFPoly(this, Uint8ClampedArray.from([1]));\n }\n\n public multiply(a: number, b: number) {\n if (a === 0 || b === 0) {\n return 0;\n }\n return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)];\n }\n\n public inverse(a: number) {\n if (a === 0) {\n throw new Error(\"Can't invert 0\");\n }\n return this.expTable[this.size - this.logTable[a] - 1];\n }\n\n public buildMonomial(degree: number, coefficient: number): GenericGFPoly {\n if (degree < 0) {\n throw new Error(\"Invalid monomial degree less than 0\");\n }\n if (coefficient === 0) {\n return this.zero;\n }\n const coefficients = new Uint8ClampedArray(degree + 1);\n coefficients[0] = coefficient;\n return new GenericGFPoly(this, coefficients);\n }\n\n public log(a: number) {\n if (a === 0) {\n throw new Error(\"Can't take log(0)\");\n }\n return this.logTable[a];\n }\n\n public exp(a: number) {\n return this.expTable[a];\n }\n}\n", "import GenericGF, { addOrSubtractGF } from \"./GenericGF\";\nimport GenericGFPoly from \"./GenericGFPoly\";\n\nfunction runEuclideanAlgorithm(field: GenericGF, a: GenericGFPoly, b: GenericGFPoly, R: number): GenericGFPoly[] {\n // Assume a's degree is >= b's\n if (a.degree() < b.degree()) {\n [a, b] = [b, a];\n }\n\n let rLast = a;\n let r = b;\n let tLast = field.zero;\n let t = field.one;\n\n // Run Euclidean algorithm until r's degree is less than R/2\n while (r.degree() >= R / 2) {\n const rLastLast = rLast;\n const tLastLast = tLast;\n rLast = r;\n tLast = t;\n\n // Divide rLastLast by rLast, with quotient in q and remainder in r\n if (rLast.isZero()) {\n // Euclidean algorithm already terminated?\n return null;\n }\n r = rLastLast;\n let q = field.zero;\n const denominatorLeadingTerm = rLast.getCoefficient(rLast.degree());\n const dltInverse = field.inverse(denominatorLeadingTerm);\n while (r.degree() >= rLast.degree() && !r.isZero()) {\n const degreeDiff = r.degree() - rLast.degree();\n const scale = field.multiply(r.getCoefficient(r.degree()), dltInverse);\n q = q.addOrSubtract(field.buildMonomial(degreeDiff, scale));\n r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));\n }\n\n t = q.multiplyPoly(tLast).addOrSubtract(tLastLast);\n\n if (r.degree() >= rLast.degree()) {\n return null;\n }\n }\n\n const sigmaTildeAtZero = t.getCoefficient(0);\n if (sigmaTildeAtZero === 0) {\n return null;\n }\n\n const inverse = field.inverse(sigmaTildeAtZero);\n return [t.multiply(inverse), r.multiply(inverse)];\n}\n\nfunction findErrorLocations(field: GenericGF, errorLocator: GenericGFPoly): number[] {\n // This is a direct application of Chien's search\n const numErrors = errorLocator.degree();\n if (numErrors === 1) {\n return [errorLocator.getCoefficient(1)];\n }\n const result: number[] = new Array(numErrors);\n let errorCount = 0;\n for (let i = 1; i < field.size && errorCount < numErrors; i++) {\n if (errorLocator.evaluateAt(i) === 0) {\n result[errorCount] = field.inverse(i);\n errorCount++;\n }\n }\n if (errorCount !== numErrors) {\n return null;\n }\n return result;\n}\n\nfunction findErrorMagnitudes(field: GenericGF, errorEvaluator: GenericGFPoly, errorLocations: number[]): number[] {\n // This is directly applying Forney's Formula\n const s = errorLocations.length;\n const result: number[] = new Array(s);\n for (let i = 0; i < s; i++) {\n const xiInverse = field.inverse(errorLocations[i]);\n let denominator = 1;\n for (let j = 0; j < s; j++) {\n if (i !== j) {\n denominator = field.multiply(denominator, addOrSubtractGF(1, field.multiply(errorLocations[j], xiInverse)));\n }\n }\n result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse), field.inverse(denominator));\n if (field.generatorBase !== 0) {\n result[i] = field.multiply(result[i], xiInverse);\n }\n }\n return result;\n}\n\nexport function decode(bytes: number[], twoS: number) {\n const outputBytes = new Uint8ClampedArray(bytes.length);\n outputBytes.set(bytes);\n\n const field = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1\n const poly = new GenericGFPoly(field, outputBytes);\n\n const syndromeCoefficients = new Uint8ClampedArray(twoS);\n let error = false;\n for (let s = 0; s < twoS; s++) {\n const evaluation = poly.evaluateAt(field.exp(s + field.generatorBase));\n syndromeCoefficients[syndromeCoefficients.length - 1 - s] = evaluation;\n if (evaluation !== 0) {\n error = true;\n }\n }\n if (!error) {\n return outputBytes;\n }\n\n const syndrome = new GenericGFPoly(field, syndromeCoefficients);\n\n const sigmaOmega = runEuclideanAlgorithm(field, field.buildMonomial(twoS, 1), syndrome, twoS);\n if (sigmaOmega === null) {\n return null;\n }\n\n const errorLocations = findErrorLocations(field, sigmaOmega[0]);\n if (errorLocations == null) {\n return null;\n }\n\n const errorMagnitudes = findErrorMagnitudes(field, sigmaOmega[1], errorLocations);\n for (let i = 0; i < errorLocations.length; i++) {\n const position = outputBytes.length - 1 - field.log(errorLocations[i]);\n if (position < 0) {\n return null;\n }\n outputBytes[position] = addOrSubtractGF(outputBytes[position], errorMagnitudes[i]);\n }\n\n return outputBytes;\n}\n", "export interface Version {\n infoBits: number;\n versionNumber: number;\n alignmentPatternCenters: number[];\n errorCorrectionLevels: Array<{\n ecCodewordsPerBlock: number;\n ecBlocks: Array<{\n numBlocks: number;\n dataCodewordsPerBlock: number;\n }>\n }>;\n}\n\nexport const VERSIONS: Version[] = [\n {\n infoBits: null,\n versionNumber: 1,\n alignmentPatternCenters: [],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 7,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 19 }],\n },\n {\n ecCodewordsPerBlock: 10,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 16 }],\n },\n {\n ecCodewordsPerBlock: 13,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 13 }],\n },\n {\n ecCodewordsPerBlock: 17,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 9 }],\n },\n ],\n },\n {\n infoBits: null,\n versionNumber: 2,\n alignmentPatternCenters: [6, 18],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 10,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 34 }],\n },\n {\n ecCodewordsPerBlock: 16,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 28 }],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 22 }],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 16 }],\n },\n ],\n },\n {\n infoBits: null,\n versionNumber: 3,\n alignmentPatternCenters: [6, 22],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 15,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 55 }],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 44 }],\n },\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 17 }],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 13 }],\n },\n ],\n },\n {\n infoBits: null,\n versionNumber: 4,\n alignmentPatternCenters: [6, 26],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 20,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 80 }],\n },\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 32 }],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 24 }],\n },\n {\n ecCodewordsPerBlock: 16,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 9 }],\n },\n ],\n },\n {\n infoBits: null,\n versionNumber: 5,\n alignmentPatternCenters: [6, 30],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [{ numBlocks: 1, dataCodewordsPerBlock: 108 }],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 43 }],\n },\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 15 },\n { numBlocks: 2, dataCodewordsPerBlock: 16 },\n ],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 11 },\n { numBlocks: 2, dataCodewordsPerBlock: 12 },\n ],\n },\n ],\n },\n {\n infoBits: null,\n versionNumber: 6,\n alignmentPatternCenters: [6, 34],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 68 }],\n },\n {\n ecCodewordsPerBlock: 16,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 27 }],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 19 }],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 15 }],\n },\n ],\n },\n {\n infoBits: 0x07C94,\n versionNumber: 7,\n alignmentPatternCenters: [6, 22, 38],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 20,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 78 }],\n },\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 31 }],\n },\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 14 },\n { numBlocks: 4, dataCodewordsPerBlock: 15 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 13 },\n { numBlocks: 1, dataCodewordsPerBlock: 14 },\n ],\n },\n ],\n },\n {\n infoBits: 0x085BC,\n versionNumber: 8,\n alignmentPatternCenters: [6, 24, 42],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 97 }],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 38 },\n { numBlocks: 2, dataCodewordsPerBlock: 39 },\n ],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 18 },\n { numBlocks: 2, dataCodewordsPerBlock: 19 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 14 },\n { numBlocks: 2, dataCodewordsPerBlock: 15 },\n ],\n },\n ],\n },\n {\n infoBits: 0x09A99,\n versionNumber: 9,\n alignmentPatternCenters: [6, 26, 46],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [{ numBlocks: 2, dataCodewordsPerBlock: 116 }],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 36 },\n { numBlocks: 2, dataCodewordsPerBlock: 37 },\n ],\n },\n {\n ecCodewordsPerBlock: 20,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 16 },\n { numBlocks: 4, dataCodewordsPerBlock: 17 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 12 },\n { numBlocks: 4, dataCodewordsPerBlock: 13 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0A4D3,\n versionNumber: 10,\n alignmentPatternCenters: [6, 28, 50],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 18,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 68 },\n { numBlocks: 2, dataCodewordsPerBlock: 69 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 43 },\n { numBlocks: 1, dataCodewordsPerBlock: 44 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 19 },\n { numBlocks: 2, dataCodewordsPerBlock: 20 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 15 },\n { numBlocks: 2, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0BBF6,\n versionNumber: 11,\n alignmentPatternCenters: [6, 30, 54],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 20,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 81 }],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 1, dataCodewordsPerBlock: 50 },\n { numBlocks: 4, dataCodewordsPerBlock: 51 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 22 },\n { numBlocks: 4, dataCodewordsPerBlock: 23 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 12 },\n { numBlocks: 8, dataCodewordsPerBlock: 13 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0C762,\n versionNumber: 12,\n alignmentPatternCenters: [6, 32, 58],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 92 },\n { numBlocks: 2, dataCodewordsPerBlock: 93 },\n ],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 36 },\n { numBlocks: 2, dataCodewordsPerBlock: 37 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 20 },\n { numBlocks: 6, dataCodewordsPerBlock: 21 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 7, dataCodewordsPerBlock: 14 },\n { numBlocks: 4, dataCodewordsPerBlock: 15 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0D847,\n versionNumber: 13,\n alignmentPatternCenters: [6, 34, 62],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [{ numBlocks: 4, dataCodewordsPerBlock: 107 }],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 37 },\n { numBlocks: 1, dataCodewordsPerBlock: 38 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 20 },\n { numBlocks: 4, dataCodewordsPerBlock: 21 },\n ],\n },\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 12, dataCodewordsPerBlock: 11 },\n { numBlocks: 4, dataCodewordsPerBlock: 12 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0E60D,\n versionNumber: 14,\n alignmentPatternCenters: [6, 26, 46, 66],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 115 },\n { numBlocks: 1, dataCodewordsPerBlock: 116 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 40 },\n { numBlocks: 5, dataCodewordsPerBlock: 41 },\n ],\n },\n {\n ecCodewordsPerBlock: 20,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 16 },\n { numBlocks: 5, dataCodewordsPerBlock: 17 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 12 },\n { numBlocks: 5, dataCodewordsPerBlock: 13 },\n ],\n },\n ],\n },\n {\n infoBits: 0x0F928,\n versionNumber: 15,\n alignmentPatternCenters: [6, 26, 48, 70],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 22,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 87 },\n { numBlocks: 1, dataCodewordsPerBlock: 88 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 41 },\n { numBlocks: 5, dataCodewordsPerBlock: 42 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 24 },\n { numBlocks: 7, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 12 },\n { numBlocks: 7, dataCodewordsPerBlock: 13 },\n ],\n },\n ],\n },\n {\n infoBits: 0x10B78,\n versionNumber: 16,\n alignmentPatternCenters: [6, 26, 50, 74],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 98 },\n { numBlocks: 1, dataCodewordsPerBlock: 99 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 7, dataCodewordsPerBlock: 45 },\n { numBlocks: 3, dataCodewordsPerBlock: 46 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [\n { numBlocks: 15, dataCodewordsPerBlock: 19 },\n { numBlocks: 2, dataCodewordsPerBlock: 20 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 15 },\n { numBlocks: 13, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1145D,\n versionNumber: 17,\n alignmentPatternCenters: [6, 30, 54, 78],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 1, dataCodewordsPerBlock: 107 },\n { numBlocks: 5, dataCodewordsPerBlock: 108 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 10, dataCodewordsPerBlock: 46 },\n { numBlocks: 1, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 1, dataCodewordsPerBlock: 22 },\n { numBlocks: 15, dataCodewordsPerBlock: 23 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 14 },\n { numBlocks: 17, dataCodewordsPerBlock: 15 },\n ],\n },\n ],\n },\n {\n infoBits: 0x12A17,\n versionNumber: 18,\n alignmentPatternCenters: [6, 30, 56, 82],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 120 },\n { numBlocks: 1, dataCodewordsPerBlock: 121 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 9, dataCodewordsPerBlock: 43 },\n { numBlocks: 4, dataCodewordsPerBlock: 44 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 17, dataCodewordsPerBlock: 22 },\n { numBlocks: 1, dataCodewordsPerBlock: 23 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 14 },\n { numBlocks: 19, dataCodewordsPerBlock: 15 },\n ],\n },\n ],\n },\n {\n infoBits: 0x13532,\n versionNumber: 19,\n alignmentPatternCenters: [6, 30, 58, 86],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 113 },\n { numBlocks: 4, dataCodewordsPerBlock: 114 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 44 },\n { numBlocks: 11, dataCodewordsPerBlock: 45 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 17, dataCodewordsPerBlock: 21 },\n { numBlocks: 4, dataCodewordsPerBlock: 22 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 9, dataCodewordsPerBlock: 13 },\n { numBlocks: 16, dataCodewordsPerBlock: 14 },\n ],\n },\n ],\n },\n {\n infoBits: 0x149A6,\n versionNumber: 20,\n alignmentPatternCenters: [6, 34, 62, 90],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 107 },\n { numBlocks: 5, dataCodewordsPerBlock: 108 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 41 },\n { numBlocks: 13, dataCodewordsPerBlock: 42 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 15, dataCodewordsPerBlock: 24 },\n { numBlocks: 5, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 15, dataCodewordsPerBlock: 15 },\n { numBlocks: 10, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x15683,\n versionNumber: 21,\n alignmentPatternCenters: [6, 28, 50, 72, 94],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 116 },\n { numBlocks: 4, dataCodewordsPerBlock: 117 },\n ],\n },\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [{ numBlocks: 17, dataCodewordsPerBlock: 42 }],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 17, dataCodewordsPerBlock: 22 },\n { numBlocks: 6, dataCodewordsPerBlock: 23 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 16 },\n { numBlocks: 6, dataCodewordsPerBlock: 17 },\n ],\n },\n ],\n },\n {\n infoBits: 0x168C9,\n versionNumber: 22,\n alignmentPatternCenters: [6, 26, 50, 74, 98],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 111 },\n { numBlocks: 7, dataCodewordsPerBlock: 112 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [{ numBlocks: 17, dataCodewordsPerBlock: 46 }],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 7, dataCodewordsPerBlock: 24 },\n { numBlocks: 16, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 24,\n ecBlocks: [{ numBlocks: 34, dataCodewordsPerBlock: 13 }],\n },\n ],\n },\n {\n infoBits: 0x177EC,\n versionNumber: 23,\n alignmentPatternCenters: [6, 30, 54, 74, 102],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 121 },\n { numBlocks: 5, dataCodewordsPerBlock: 122 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 47 },\n { numBlocks: 14, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 24 },\n { numBlocks: 14, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 16, dataCodewordsPerBlock: 15 },\n { numBlocks: 14, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x18EC4,\n versionNumber: 24,\n alignmentPatternCenters: [6, 28, 54, 80, 106],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 117 },\n { numBlocks: 4, dataCodewordsPerBlock: 118 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 45 },\n { numBlocks: 14, dataCodewordsPerBlock: 46 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 24 },\n { numBlocks: 16, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 30, dataCodewordsPerBlock: 16 },\n { numBlocks: 2, dataCodewordsPerBlock: 17 },\n ],\n },\n ],\n },\n {\n infoBits: 0x191E1,\n versionNumber: 25,\n alignmentPatternCenters: [6, 32, 58, 84, 110],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 26,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 106 },\n { numBlocks: 4, dataCodewordsPerBlock: 107 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 47 },\n { numBlocks: 13, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 7, dataCodewordsPerBlock: 24 },\n { numBlocks: 22, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 22, dataCodewordsPerBlock: 15 },\n { numBlocks: 13, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1AFAB,\n versionNumber: 26,\n alignmentPatternCenters: [6, 30, 58, 86, 114],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 10, dataCodewordsPerBlock: 114 },\n { numBlocks: 2, dataCodewordsPerBlock: 115 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 46 },\n { numBlocks: 4, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 28, dataCodewordsPerBlock: 22 },\n { numBlocks: 6, dataCodewordsPerBlock: 23 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 33, dataCodewordsPerBlock: 16 },\n { numBlocks: 4, dataCodewordsPerBlock: 17 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1B08E,\n versionNumber: 27,\n alignmentPatternCenters: [6, 34, 62, 90, 118],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 122 },\n { numBlocks: 4, dataCodewordsPerBlock: 123 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 22, dataCodewordsPerBlock: 45 },\n { numBlocks: 3, dataCodewordsPerBlock: 46 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 8, dataCodewordsPerBlock: 23 },\n { numBlocks: 26, dataCodewordsPerBlock: 24 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 12, dataCodewordsPerBlock: 15 },\n { numBlocks: 28, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1CC1A,\n versionNumber: 28,\n alignmentPatternCenters: [6, 26, 50, 74, 98, 122],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 117 },\n { numBlocks: 10, dataCodewordsPerBlock: 118 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 3, dataCodewordsPerBlock: 45 },\n { numBlocks: 23, dataCodewordsPerBlock: 46 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 24 },\n { numBlocks: 31, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 15 },\n { numBlocks: 31, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1D33F,\n versionNumber: 29,\n alignmentPatternCenters: [6, 30, 54, 78, 102, 126],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 7, dataCodewordsPerBlock: 116 },\n { numBlocks: 7, dataCodewordsPerBlock: 117 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 21, dataCodewordsPerBlock: 45 },\n { numBlocks: 7, dataCodewordsPerBlock: 46 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 1, dataCodewordsPerBlock: 23 },\n { numBlocks: 37, dataCodewordsPerBlock: 24 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 15 },\n { numBlocks: 26, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1ED75,\n versionNumber: 30,\n alignmentPatternCenters: [6, 26, 52, 78, 104, 130],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 5, dataCodewordsPerBlock: 115 },\n { numBlocks: 10, dataCodewordsPerBlock: 116 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 47 },\n { numBlocks: 10, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 15, dataCodewordsPerBlock: 24 },\n { numBlocks: 25, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 23, dataCodewordsPerBlock: 15 },\n { numBlocks: 25, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x1F250,\n versionNumber: 31,\n alignmentPatternCenters: [6, 30, 56, 82, 108, 134],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 13, dataCodewordsPerBlock: 115 },\n { numBlocks: 3, dataCodewordsPerBlock: 116 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 46 },\n { numBlocks: 29, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 42, dataCodewordsPerBlock: 24 },\n { numBlocks: 1, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 23, dataCodewordsPerBlock: 15 },\n { numBlocks: 28, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x209D5,\n versionNumber: 32,\n alignmentPatternCenters: [6, 34, 60, 86, 112, 138],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [{ numBlocks: 17, dataCodewordsPerBlock: 115 }],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 10, dataCodewordsPerBlock: 46 },\n { numBlocks: 23, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 10, dataCodewordsPerBlock: 24 },\n { numBlocks: 35, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 15 },\n { numBlocks: 35, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x216F0,\n versionNumber: 33,\n alignmentPatternCenters: [6, 30, 58, 86, 114, 142],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 17, dataCodewordsPerBlock: 115 },\n { numBlocks: 1, dataCodewordsPerBlock: 116 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 14, dataCodewordsPerBlock: 46 },\n { numBlocks: 21, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 29, dataCodewordsPerBlock: 24 },\n { numBlocks: 19, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 11, dataCodewordsPerBlock: 15 },\n { numBlocks: 46, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x228BA,\n versionNumber: 34,\n alignmentPatternCenters: [6, 34, 62, 90, 118, 146],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 13, dataCodewordsPerBlock: 115 },\n { numBlocks: 6, dataCodewordsPerBlock: 116 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 14, dataCodewordsPerBlock: 46 },\n { numBlocks: 23, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 44, dataCodewordsPerBlock: 24 },\n { numBlocks: 7, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 59, dataCodewordsPerBlock: 16 },\n { numBlocks: 1, dataCodewordsPerBlock: 17 },\n ],\n },\n ],\n },\n {\n infoBits: 0x2379F,\n versionNumber: 35,\n alignmentPatternCenters: [6, 30, 54, 78, 102, 126, 150],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 12, dataCodewordsPerBlock: 121 },\n { numBlocks: 7, dataCodewordsPerBlock: 122 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 12, dataCodewordsPerBlock: 47 },\n { numBlocks: 26, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 39, dataCodewordsPerBlock: 24 },\n { numBlocks: 14, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 22, dataCodewordsPerBlock: 15 },\n { numBlocks: 41, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x24B0B,\n versionNumber: 36,\n alignmentPatternCenters: [ 6, 24, 50, 76, 102, 128, 154 ],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 121 },\n { numBlocks: 14, dataCodewordsPerBlock: 122 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 6, dataCodewordsPerBlock: 47 },\n { numBlocks: 34, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 46, dataCodewordsPerBlock: 24 },\n { numBlocks: 10, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 2, dataCodewordsPerBlock: 15 },\n { numBlocks: 64, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x2542E,\n versionNumber: 37,\n alignmentPatternCenters: [ 6, 28, 54, 80, 106, 132, 158 ],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 17, dataCodewordsPerBlock: 122 },\n { numBlocks: 4, dataCodewordsPerBlock: 123 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 29, dataCodewordsPerBlock: 46 },\n { numBlocks: 14, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 49, dataCodewordsPerBlock: 24 },\n { numBlocks: 10, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 24, dataCodewordsPerBlock: 15 },\n { numBlocks: 46, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x26A64,\n versionNumber: 38,\n alignmentPatternCenters: [ 6, 32, 58, 84, 110, 136, 162 ],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 4, dataCodewordsPerBlock: 122 },\n { numBlocks: 18, dataCodewordsPerBlock: 123 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 13, dataCodewordsPerBlock: 46 },\n { numBlocks: 32, dataCodewordsPerBlock: 47 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 48, dataCodewordsPerBlock: 24 },\n { numBlocks: 14, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 42, dataCodewordsPerBlock: 15 },\n { numBlocks: 32, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x27541,\n versionNumber: 39,\n alignmentPatternCenters: [ 6, 26, 54, 82, 110, 138, 166 ],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 20, dataCodewordsPerBlock: 117 },\n { numBlocks: 4, dataCodewordsPerBlock: 118 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 40, dataCodewordsPerBlock: 47 },\n { numBlocks: 7, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 43, dataCodewordsPerBlock: 24 },\n { numBlocks: 22, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 10, dataCodewordsPerBlock: 15 },\n { numBlocks: 67, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n {\n infoBits: 0x28C69,\n versionNumber: 40,\n alignmentPatternCenters: [ 6, 30, 58, 86, 114, 142, 170 ],\n errorCorrectionLevels: [\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 19, dataCodewordsPerBlock: 118 },\n { numBlocks: 6, dataCodewordsPerBlock: 119 },\n ],\n },\n {\n ecCodewordsPerBlock: 28,\n ecBlocks: [\n { numBlocks: 18, dataCodewordsPerBlock: 47 },\n { numBlocks: 31, dataCodewordsPerBlock: 48 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 34, dataCodewordsPerBlock: 24 },\n { numBlocks: 34, dataCodewordsPerBlock: 25 },\n ],\n },\n {\n ecCodewordsPerBlock: 30,\n ecBlocks: [\n { numBlocks: 20, dataCodewordsPerBlock: 15 },\n { numBlocks: 61, dataCodewordsPerBlock: 16 },\n ],\n },\n ],\n },\n];\n", "import { BitMatrix } from \"../BitMatrix\";\nimport { Point } from \"../Point\";\nimport { decode as decodeData, DecodedQR } from \"./decodeData\";\nimport { decode as rsDecode } from \"./reedsolomon\";\nimport { Version, VERSIONS } from \"./version\";\n\n// tslint:disable:no-bitwise\nfunction numBitsDiffering(x: number, y: number) {\n let z = x ^ y;\n let bitCount = 0;\n while (z) {\n bitCount++;\n z &= z - 1;\n }\n return bitCount;\n}\n\nfunction pushBit(bit: any, byte: number) {\n return (byte << 1) | bit;\n}\n// tslint:enable:no-bitwise\n\nconst FORMAT_INFO_TABLE = [\n { bits: 0x5412, formatInfo: { errorCorrectionLevel: 1, dataMask: 0 } },\n { bits: 0x5125, formatInfo: { errorCorrectionLevel: 1, dataMask: 1 } },\n { bits: 0x5E7C, formatInfo: { errorCorrectionLevel: 1, dataMask: 2 } },\n { bits: 0x5B4B, formatInfo: { errorCorrectionLevel: 1, dataMask: 3 } },\n { bits: 0x45F9, formatInfo: { errorCorrectionLevel: 1, dataMask: 4 } },\n { bits: 0x40CE, formatInfo: { errorCorrectionLevel: 1, dataMask: 5 } },\n { bits: 0x4F97, formatInfo: { errorCorrectionLevel: 1, dataMask: 6 } },\n { bits: 0x4AA0, formatInfo: { errorCorrectionLevel: 1, dataMask: 7 } },\n { bits: 0x77C4, formatInfo: { errorCorrectionLevel: 0, dataMask: 0 } },\n { bits: 0x72F3, formatInfo: { errorCorrectionLevel: 0, dataMask: 1 } },\n { bits: 0x7DAA, formatInfo: { errorCorrectionLevel: 0, dataMask: 2 } },\n { bits: 0x789D, formatInfo: { errorCorrectionLevel: 0, dataMask: 3 } },\n { bits: 0x662F, formatInfo: { errorCorrectionLevel: 0, dataMask: 4 } },\n { bits: 0x6318, formatInfo: { errorCorrectionLevel: 0, dataMask: 5 } },\n { bits: 0x6C41, formatInfo: { errorCorrectionLevel: 0, dataMask: 6 } },\n { bits: 0x6976, formatInfo: { errorCorrectionLevel: 0, dataMask: 7 } },\n { bits: 0x1689, formatInfo: { errorCorrectionLevel: 3, dataMask: 0 } },\n { bits: 0x13BE, formatInfo: { errorCorrectionLevel: 3, dataMask: 1 } },\n { bits: 0x1CE7, formatInfo: { errorCorrectionLevel: 3, dataMask: 2 } },\n { bits: 0x19D0, formatInfo: { errorCorrectionLevel: 3, dataMask: 3 } },\n { bits: 0x0762, formatInfo: { errorCorrectionLevel: 3, dataMask: 4 } },\n { bits: 0x0255, formatInfo: { errorCorrectionLevel: 3, dataMask: 5 } },\n { bits: 0x0D0C, formatInfo: { errorCorrectionLevel: 3, dataMask: 6 } },\n { bits: 0x083B, formatInfo: { errorCorrectionLevel: 3, dataMask: 7 } },\n { bits: 0x355F, formatInfo: { errorCorrectionLevel: 2, dataMask: 0 } },\n { bits: 0x3068, formatInfo: { errorCorrectionLevel: 2, dataMask: 1 } },\n { bits: 0x3F31, formatInfo: { errorCorrectionLevel: 2, dataMask: 2 } },\n { bits: 0x3A06, formatInfo: { errorCorrectionLevel: 2, dataMask: 3 } },\n { bits: 0x24B4, formatInfo: { errorCorrectionLevel: 2, dataMask: 4 } },\n { bits: 0x2183, formatInfo: { errorCorrectionLevel: 2, dataMask: 5 } },\n { bits: 0x2EDA, formatInfo: { errorCorrectionLevel: 2, dataMask: 6 } },\n { bits: 0x2BED, formatInfo: { errorCorrectionLevel: 2, dataMask: 7 } },\n];\n\nconst DATA_MASKS = [\n (p: Point) => ((p.y + p.x) % 2) === 0,\n (p: Point) => (p.y % 2) === 0,\n (p: Point) => p.x % 3 === 0,\n (p: Point) => (p.y + p.x) % 3 === 0,\n (p: Point) => (Math.floor(p.y / 2) + Math.floor(p.x / 3)) % 2 === 0,\n (p: Point) => ((p.x * p.y) % 2) + ((p.x * p.y) % 3) === 0,\n (p: Point) => ((((p.y * p.x) % 2) + (p.y * p.x) % 3) % 2) === 0,\n (p: Point) => ((((p.y + p.x) % 2) + (p.y * p.x) % 3) % 2) === 0,\n];\n\ninterface FormatInformation {\n errorCorrectionLevel: number;\n dataMask: number;\n}\n\nfunction buildFunctionPatternMask(version: Version): BitMatrix {\n const dimension = 17 + 4 * version.versionNumber;\n const matrix = BitMatrix.createEmpty(dimension, dimension);\n\n matrix.setRegion(0, 0, 9, 9, true); // Top left finder pattern + separator + format\n matrix.setRegion(dimension - 8, 0, 8, 9, true); // Top right finder pattern + separator + format\n matrix.setRegion(0, dimension - 8, 9, 8, true); // Bottom left finder pattern + separator + format\n\n // Alignment patterns\n for (const x of version.alignmentPatternCenters) {\n for (const y of version.alignmentPatternCenters) {\n if (!(x === 6 && y === 6 || x === 6 && y === dimension - 7 || x === dimension - 7 && y === 6)) {\n matrix.setRegion(x - 2, y - 2, 5, 5, true);\n }\n }\n }\n\n matrix.setRegion(6, 9, 1, dimension - 17, true); // Vertical timing pattern\n matrix.setRegion(9, 6, dimension - 17, 1, true); // Horizontal timing pattern\n\n if (version.versionNumber > 6) {\n matrix.setRegion(dimension - 11, 0, 3, 6, true); // Version info, top right\n matrix.setRegion(0, dimension - 11, 6, 3, true); // Version info, bottom left\n }\n\n return matrix;\n}\n\nfunction readCodewords(matrix: BitMatrix, version: Version, formatInfo: FormatInformation) {\n const dataMask = DATA_MASKS[formatInfo.dataMask];\n const dimension = matrix.height;\n\n const functionPatternMask = buildFunctionPatternMask(version);\n\n const codewords: number[] = [];\n let currentByte = 0;\n let bitsRead = 0;\n\n // Read columns in pairs, from right to left\n let readingUp = true;\n for (let columnIndex = dimension - 1; columnIndex > 0; columnIndex -= 2) {\n if (columnIndex === 6) { // Skip whole column with vertical alignment pattern;\n columnIndex--;\n }\n for (let i = 0; i < dimension; i++) {\n const y = readingUp ? dimension - 1 - i : i;\n for (let columnOffset = 0; columnOffset < 2; columnOffset++) {\n const x = columnIndex - columnOffset;\n if (!functionPatternMask.get(x, y)) {\n bitsRead++;\n let bit = matrix.get(x, y);\n if (dataMask({y, x})) {\n bit = !bit;\n }\n currentByte = pushBit(bit, currentByte);\n if (bitsRead === 8) { // Whole bytes\n codewords.push(currentByte);\n bitsRead = 0;\n currentByte = 0;\n }\n }\n }\n }\n readingUp = !readingUp;\n }\n return codewords;\n}\n\nfunction readVersion(matrix: BitMatrix): Version {\n const dimension = matrix.height;\n\n const provisionalVersion = Math.floor((dimension - 17) / 4);\n if (provisionalVersion <= 6) { // 6 and under dont have version info in the QR code\n return VERSIONS[provisionalVersion - 1];\n }\n\n let topRightVersionBits = 0;\n for (let y = 5; y >= 0; y--) {\n for (let x = dimension - 9; x >= dimension - 11; x--) {\n topRightVersionBits = pushBit(matrix.get(x, y), topRightVersionBits);\n }\n }\n\n let bottomLeftVersionBits = 0;\n for (let x = 5; x >= 0; x--) {\n for (let y = dimension - 9; y >= dimension - 11; y--) {\n bottomLeftVersionBits = pushBit(matrix.get(x, y), bottomLeftVersionBits);\n }\n }\n\n let bestDifference = Infinity;\n let bestVersion: Version;\n for (const version of VERSIONS) {\n if (version.infoBits === topRightVersionBits || version.infoBits === bottomLeftVersionBits) {\n return version;\n }\n\n let difference = numBitsDiffering(topRightVersionBits, version.infoBits);\n if (difference < bestDifference) {\n bestVersion = version;\n bestDifference = difference;\n }\n\n difference = numBitsDiffering(bottomLeftVersionBits, version.infoBits);\n if (difference < bestDifference) {\n bestVersion = version;\n bestDifference = difference;\n }\n }\n // We can tolerate up to 3 bits of error since no two version info codewords will\n // differ in less than 8 bits.\n if (bestDifference <= 3) {\n return bestVersion;\n }\n}\n\nfunction readFormatInformation(matrix: BitMatrix) {\n let topLeftFormatInfoBits = 0;\n for (let x = 0; x <= 8; x++) {\n if (x !== 6) { // Skip timing pattern bit\n topLeftFormatInfoBits = pushBit(matrix.get(x, 8), topLeftFormatInfoBits);\n }\n }\n for (let y = 7; y >= 0; y--) {\n if (y !== 6) { // Skip timing pattern bit\n topLeftFormatInfoBits = pushBit(matrix.get(8, y), topLeftFormatInfoBits);\n }\n }\n\n const dimension = matrix.height;\n let topRightBottomRightFormatInfoBits = 0;\n for (let y = dimension - 1; y >= dimension - 7; y--) { // bottom left\n topRightBottomRightFormatInfoBits = pushBit(matrix.get(8, y), topRightBottomRightFormatInfoBits);\n }\n for (let x = dimension - 8; x < dimension; x++) { // top right\n topRightBottomRightFormatInfoBits = pushBit(matrix.get(x, 8), topRightBottomRightFormatInfoBits);\n }\n\n let bestDifference = Infinity;\n let bestFormatInfo = null;\n for (const {bits, formatInfo} of FORMAT_INFO_TABLE) {\n if (bits === topLeftFormatInfoBits || bits === topRightBottomRightFormatInfoBits) {\n return formatInfo;\n }\n let difference = numBitsDiffering(topLeftFormatInfoBits, bits);\n if (difference < bestDifference) {\n bestFormatInfo = formatInfo;\n bestDifference = difference;\n }\n if (topLeftFormatInfoBits !== topRightBottomRightFormatInfoBits) { // also try the other option\n difference = numBitsDiffering(topRightBottomRightFormatInfoBits, bits);\n if (difference < bestDifference) {\n bestFormatInfo = formatInfo;\n bestDifference = difference;\n }\n }\n }\n // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits differing means we found a match\n if (bestDifference <= 3) {\n return bestFormatInfo;\n }\n return null;\n}\n\nfunction getDataBlocks(codewords: number[], version: Version, ecLevel: number) {\n const ecInfo = version.errorCorrectionLevels[ecLevel];\n const dataBlocks: Array<{\n numDataCodewords: number;\n codewords: number[];\n }> = [];\n\n let totalCodewords = 0;\n ecInfo.ecBlocks.forEach(block => {\n for (let i = 0; i < block.numBlocks; i++) {\n dataBlocks.push({ numDataCodewords: block.dataCodewordsPerBlock, codewords: [] });\n totalCodewords += block.dataCodewordsPerBlock + ecInfo.ecCodewordsPerBlock;\n }\n });\n\n // In some cases the QR code will be malformed enough that we pull off more or less than we should.\n // If we pull off less there's nothing we can do.\n // If we pull off more we can safely truncate\n if (codewords.length < totalCodewords) {\n return null;\n }\n codewords = codewords.slice(0, totalCodewords);\n\n const shortBlockSize = ecInfo.ecBlocks[0].dataCodewordsPerBlock;\n // Pull codewords to fill the blocks up to the minimum size\n for (let i = 0; i < shortBlockSize; i++) {\n for (const dataBlock of dataBlocks) {\n dataBlock.codewords.push(codewords.shift());\n }\n }\n\n // If there are any large blocks, pull codewords to fill the last element of those\n if (ecInfo.ecBlocks.length > 1) {\n const smallBlockCount = ecInfo.ecBlocks[0].numBlocks;\n const largeBlockCount = ecInfo.ecBlocks[1].numBlocks;\n for (let i = 0; i < largeBlockCount; i++) {\n dataBlocks[smallBlockCount + i].codewords.push(codewords.shift());\n }\n }\n\n // Add the rest of the codewords to the blocks. These are the error correction codewords.\n while (codewords.length > 0) {\n for (const dataBlock of dataBlocks) {\n dataBlock.codewords.push(codewords.shift());\n }\n }\n\n return dataBlocks;\n}\n\nfunction decodeMatrix(matrix: BitMatrix) {\n const version = readVersion(matrix);\n if (!version) {\n return null;\n }\n\n const formatInfo = readFormatInformation(matrix);\n if (!formatInfo) {\n return null;\n }\n\n const codewords = readCodewords(matrix, version, formatInfo);\n const dataBlocks = getDataBlocks(codewords, version, formatInfo.errorCorrectionLevel);\n if (!dataBlocks) {\n return null;\n }\n\n // Count total number of data bytes\n const totalBytes = dataBlocks.reduce((a, b) => a + b.numDataCodewords, 0);\n const resultBytes = new Uint8ClampedArray(totalBytes);\n\n let resultIndex = 0;\n for (const dataBlock of dataBlocks) {\n const correctedBytes = rsDecode(dataBlock.codewords, dataBlock.codewords.length - dataBlock.numDataCodewords);\n if (!correctedBytes) {\n return null;\n }\n for (let i = 0; i < dataBlock.numDataCodewords; i++) {\n resultBytes[resultIndex++] = correctedBytes[i];\n }\n }\n\n try {\n return decodeData(resultBytes, version.versionNumber);\n } catch {\n return null;\n }\n}\n\nexport function decode(matrix: BitMatrix): DecodedQR {\n if (matrix == null) {\n return null;\n }\n const result = decodeMatrix(matrix);\n if (result) {\n return result;\n }\n // Decoding didn't work, try mirroring the QR across the topLeft -> bottomRight line.\n for (let x = 0; x < matrix.width; x++) {\n for (let y = x + 1; y < matrix.height; y++) {\n if (matrix.get(x, y) !== matrix.get(y, x)) {\n matrix.set(x, y, !matrix.get(x, y));\n matrix.set(y, x, !matrix.get(y, x));\n }\n }\n }\n return decodeMatrix(matrix);\n}\n", "import {BitMatrix} from \"../BitMatrix\";\nimport {Point, QRLocation} from \"../locator\";\n\ninterface PerspectiveTransform {\n a11: number;\n a21: number;\n a31: number;\n a12: number;\n a22: number;\n a32: number;\n a13: number;\n a23: number;\n a33: number;\n}\n\nfunction squareToQuadrilateral(p1: Point, p2: Point, p3: Point, p4: Point): PerspectiveTransform {\n const dx3 = p1.x - p2.x + p3.x - p4.x;\n const dy3 = p1.y - p2.y + p3.y - p4.y;\n if (dx3 === 0 && dy3 === 0) { // Affine\n return {\n a11: p2.x - p1.x,\n a12: p2.y - p1.y,\n a13: 0,\n a21: p3.x - p2.x,\n a22: p3.y - p2.y,\n a23: 0,\n a31: p1.x,\n a32: p1.y,\n a33: 1,\n };\n } else {\n const dx1 = p2.x - p3.x;\n const dx2 = p4.x - p3.x;\n const dy1 = p2.y - p3.y;\n const dy2 = p4.y - p3.y;\n const denominator = dx1 * dy2 - dx2 * dy1;\n const a13 = (dx3 * dy2 - dx2 * dy3) / denominator;\n const a23 = (dx1 * dy3 - dx3 * dy1) / denominator;\n return {\n a11: p2.x - p1.x + a13 * p2.x,\n a12: p2.y - p1.y + a13 * p2.y,\n a13,\n a21: p4.x - p1.x + a23 * p4.x,\n a22: p4.y - p1.y + a23 * p4.y,\n a23,\n a31: p1.x,\n a32: p1.y,\n a33: 1,\n };\n }\n}\n\nfunction quadrilateralToSquare(p1: Point, p2: Point, p3: Point, p4: Point): PerspectiveTransform {\n // Here, the adjoint serves as the inverse:\n const sToQ = squareToQuadrilateral(p1, p2, p3, p4);\n return {\n a11: sToQ.a22 * sToQ.a33 - sToQ.a23 * sToQ.a32,\n a12: sToQ.a13 * sToQ.a32 - sToQ.a12 * sToQ.a33,\n a13: sToQ.a12 * sToQ.a23 - sToQ.a13 * sToQ.a22,\n a21: sToQ.a23 * sToQ.a31 - sToQ.a21 * sToQ.a33,\n a22: sToQ.a11 * sToQ.a33 - sToQ.a13 * sToQ.a31,\n a23: sToQ.a13 * sToQ.a21 - sToQ.a11 * sToQ.a23,\n a31: sToQ.a21 * sToQ.a32 - sToQ.a22 * sToQ.a31,\n a32: sToQ.a12 * sToQ.a31 - sToQ.a11 * sToQ.a32,\n a33: sToQ.a11 * sToQ.a22 - sToQ.a12 * sToQ.a21,\n };\n}\n\nfunction times(a: PerspectiveTransform, b: PerspectiveTransform): PerspectiveTransform {\n return {\n a11: a.a11 * b.a11 + a.a21 * b.a12 + a.a31 * b.a13,\n a12: a.a12 * b.a11 + a.a22 * b.a12 + a.a32 * b.a13,\n a13: a.a13 * b.a11 + a.a23 * b.a12 + a.a33 * b.a13,\n a21: a.a11 * b.a21 + a.a21 * b.a22 + a.a31 * b.a23,\n a22: a.a12 * b.a21 + a.a22 * b.a22 + a.a32 * b.a23,\n a23: a.a13 * b.a21 + a.a23 * b.a22 + a.a33 * b.a23,\n a31: a.a11 * b.a31 + a.a21 * b.a32 + a.a31 * b.a33,\n a32: a.a12 * b.a31 + a.a22 * b.a32 + a.a32 * b.a33,\n a33: a.a13 * b.a31 + a.a23 * b.a32 + a.a33 * b.a33,\n };\n}\n\nexport function extract(image: BitMatrix, location: QRLocation) {\n const qToS = quadrilateralToSquare(\n {x: 3.5, y: 3.5},\n {x: location.dimension - 3.5, y: 3.5},\n {x: location.dimension - 6.5, y: location.dimension - 6.5},\n {x: 3.5, y: location.dimension - 3.5},\n );\n const sToQ = squareToQuadrilateral(location.topLeft, location.topRight, location.alignmentPattern, location.bottomLeft);\n const transform = times(sToQ, qToS);\n\n const matrix = BitMatrix.createEmpty(location.dimension, location.dimension);\n const mappingFunction = (x: number, y: number) => {\n const denominator = transform.a13 * x + transform.a23 * y + transform.a33;\n return {\n x: (transform.a11 * x + transform.a21 * y + transform.a31) / denominator,\n y: (transform.a12 * x + transform.a22 * y + transform.a32) / denominator,\n };\n };\n\n for (let y = 0; y < location.dimension; y++) {\n for (let x = 0; x < location.dimension; x++) {\n const xValue = x + 0.5;\n const yValue = y + 0.5;\n const sourcePixel = mappingFunction(xValue, yValue);\n matrix.set(x, y, image.get(Math.floor(sourcePixel.x), Math.floor(sourcePixel.y)));\n }\n }\n\n return {\n matrix,\n mappingFunction,\n };\n}\n", "import { BitMatrix } from \"../BitMatrix\";\n\nconst MAX_FINDERPATTERNS_TO_SEARCH = 5;\nconst MIN_QUAD_RATIO = 0.5;\nconst MAX_QUAD_RATIO = 1.5;\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface QRLocation {\n topRight: Point;\n bottomLeft: Point;\n topLeft: Point;\n alignmentPattern: Point;\n dimension: number;\n}\n\nconst distance = (a: Point, b: Point) => Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2);\n\nfunction sum(values: number[]) {\n return values.reduce((a, b) => a + b);\n}\n\n// Takes three finder patterns and organizes them into topLeft, topRight, etc\nfunction reorderFinderPatterns(pattern1: Point, pattern2: Point, pattern3: Point) {\n // Find distances between pattern centers\n const oneTwoDistance = distance(pattern1, pattern2);\n const twoThreeDistance = distance(pattern2, pattern3);\n const oneThreeDistance = distance(pattern1, pattern3);\n\n let bottomLeft: Point;\n let topLeft: Point;\n let topRight: Point;\n\n // Assume one closest to other two is B; A and C will just be guesses at first\n if (twoThreeDistance >= oneTwoDistance && twoThreeDistance >= oneThreeDistance) {\n [bottomLeft, topLeft, topRight] = [pattern2, pattern1, pattern3];\n } else if (oneThreeDistance >= twoThreeDistance && oneThreeDistance >= oneTwoDistance) {\n [bottomLeft, topLeft, topRight] = [pattern1, pattern2, pattern3];\n } else {\n [bottomLeft, topLeft, topRight] = [pattern1, pattern3, pattern2];\n }\n\n // Use cross product to figure out whether bottomLeft (A) and topRight (C) are correct or flipped in relation to topLeft (B)\n // This asks whether BC x BA has a positive z component, which is the arrangement we want. If it's negative, then\n // we've got it flipped around and should swap topRight and bottomLeft.\n if (((topRight.x - topLeft.x) * (bottomLeft.y - topLeft.y)) - ((topRight.y - topLeft.y) * (bottomLeft.x - topLeft.x)) < 0) {\n [bottomLeft, topRight] = [topRight, bottomLeft];\n }\n\n return { bottomLeft, topLeft, topRight };\n}\n\n// Computes the dimension (number of modules on a side) of the QR Code based on the position of the finder patterns\nfunction computeDimension(topLeft: Point, topRight: Point, bottomLeft: Point, matrix: BitMatrix) {\n const moduleSize = (\n sum(countBlackWhiteRun(topLeft, bottomLeft, matrix, 5)) / 7 + // Divide by 7 since the ratio is 1:1:3:1:1\n sum(countBlackWhiteRun(topLeft, topRight, matrix, 5)) / 7 +\n sum(countBlackWhiteRun(bottomLeft, topLeft, matrix, 5)) / 7 +\n sum(countBlackWhiteRun(topRight, topLeft, matrix, 5)) / 7\n ) / 4;\n\n if (moduleSize < 1) {\n throw new Error(\"Invalid module size\");\n }\n\n const topDimension = Math.round(distance(topLeft, topRight) / moduleSize);\n const sideDimension = Math.round(distance(topLeft, bottomLeft) / moduleSize);\n let dimension = Math.floor((topDimension + sideDimension) / 2) + 7;\n switch (dimension % 4) {\n case 0:\n dimension++;\n break;\n case 2:\n dimension--;\n break;\n }\n return { dimension, moduleSize };\n}\n\n// Takes an origin point and an end point and counts the sizes of the black white run from the origin towards the end point.\n// Returns an array of elements, representing the pixel size of the black white run.\n// Uses a variant of http://en.wikipedia.org/wiki/Bresenham's_line_algorithm\nfunction countBlackWhiteRunTowardsPoint(origin: Point, end: Point, matrix: BitMatrix, length: number) {\n const switchPoints: Point[] = [{x: Math.floor(origin.x), y: Math.floor(origin.y)}];\n const steep = Math.abs(end.y - origin.y) > Math.abs(end.x - origin.x);\n\n let fromX: number;\n let fromY: number;\n let toX: number;\n let toY: number;\n if (steep) {\n fromX = Math.floor(origin.y);\n fromY = Math.floor(origin.x);\n toX = Math.floor(end.y);\n toY = Math.floor(end.x);\n } else {\n fromX = Math.floor(origin.x);\n fromY = Math.floor(origin.y);\n toX = Math.floor(end.x);\n toY = Math.floor(end.y);\n }\n\n const dx = Math.abs(toX - fromX);\n const dy = Math.abs(toY - fromY);\n let error = Math.floor(-dx / 2);\n const xStep = fromX < toX ? 1 : -1;\n const yStep = fromY < toY ? 1 : -1;\n\n let currentPixel = true;\n // Loop up until x == toX, but not beyond\n for (let x = fromX, y = fromY; x !== toX + xStep; x += xStep) {\n // Does current pixel mean we have moved white to black or vice versa?\n // Scanning black in state 0,2 and white in state 1, so if we find the wrong\n // color, advance to next state or end if we are in state 2 already\n const realX = steep ? y : x;\n const realY = steep ? x : y;\n if (matrix.get(realX, realY) !== currentPixel) {\n currentPixel = !currentPixel;\n switchPoints.push({x: realX, y: realY});\n if (switchPoints.length === length + 1) {\n break;\n }\n }\n error += dy;\n if (error > 0) {\n if (y === toY) {\n break;\n }\n y += yStep;\n error -= dx;\n }\n }\n const distances: number[] = [];\n for (let i = 0; i < length; i++) {\n if (switchPoints[i] && switchPoints[i + 1]) {\n distances.push(distance(switchPoints[i], switchPoints[i + 1]));\n } else {\n distances.push(0);\n }\n }\n return distances;\n}\n\n// Takes an origin point and an end point and counts the sizes of the black white run in the origin point\n// along the line that intersects with the end point. Returns an array of elements, representing the pixel sizes\n// of the black white run. Takes a length which represents the number of switches from black to white to look for.\nfunction countBlackWhiteRun(origin: Point, end: Point, matrix: BitMatrix, length: number) {\n const rise = end.y - origin.y;\n const run = end.x - origin.x;\n\n const towardsEnd = countBlackWhiteRunTowardsPoint(origin, end, matrix, Math.ceil(length / 2));\n const awayFromEnd = countBlackWhiteRunTowardsPoint(origin, {x: origin.x - run, y: origin.y - rise}, matrix, Math.ceil(length / 2));\n\n const middleValue = towardsEnd.shift() + awayFromEnd.shift() - 1; // Substract one so we don't double count a pixel\n return awayFromEnd.concat(middleValue).concat(...towardsEnd);\n}\n\n// Takes in a black white run and an array of expected ratios. Returns the average size of the run as well as the \"error\" -\n// that is the amount the run diverges from the expected ratio\nfunction scoreBlackWhiteRun(sequence: number[], ratios: number[]) {\n const averageSize = sum(sequence) / sum(ratios);\n let error = 0;\n ratios.forEach((ratio, i) => {\n error += (sequence[i] - ratio * averageSize) ** 2;\n });\n\n return { averageSize, error };\n}\n\n// Takes an X,Y point and an array of sizes and scores the point against those ratios.\n// For example for a finder pattern takes the ratio list of 1:1:3:1:1 and checks horizontal, vertical and diagonal ratios\n// against that.\nfunction scorePattern(point: Point, ratios: number[], matrix: BitMatrix) {\n try {\n const horizontalRun = countBlackWhiteRun(point, {x: -1, y: point.y}, matrix, ratios.length);\n const verticalRun = countBlackWhiteRun(point, {x: point.x, y: -1}, matrix, ratios.length);\n\n const topLeftPoint = {\n x: Math.max(0, point.x - point.y) - 1,\n y: Math.max(0, point.y - point.x) - 1,\n };\n const topLeftBottomRightRun = countBlackWhiteRun(point, topLeftPoint, matrix, ratios.length);\n\n const bottomLeftPoint = {\n x: Math.min(matrix.width, point.x + point.y) + 1,\n y: Math.min(matrix.height, point.y + point.x) + 1,\n };\n const bottomLeftTopRightRun = countBlackWhiteRun(point, bottomLeftPoint, matrix, ratios.length);\n\n const horzError = scoreBlackWhiteRun(horizontalRun, ratios);\n const vertError = scoreBlackWhiteRun(verticalRun, ratios);\n const diagDownError = scoreBlackWhiteRun(topLeftBottomRightRun, ratios);\n const diagUpError = scoreBlackWhiteRun(bottomLeftTopRightRun, ratios);\n\n const ratioError = Math.sqrt(horzError.error * horzError.error +\n vertError.error * vertError.error +\n diagDownError.error * diagDownError.error +\n diagUpError.error * diagUpError.error);\n\n const avgSize = (horzError.averageSize + vertError.averageSize + diagDownError.averageSize + diagUpError.averageSize) / 4;\n\n const sizeError = ((horzError.averageSize - avgSize) ** 2 +\n (vertError.averageSize - avgSize) ** 2 +\n (diagDownError.averageSize - avgSize) ** 2 +\n (diagUpError.averageSize - avgSize) ** 2) / avgSize;\n return ratioError + sizeError;\n } catch {\n return Infinity;\n }\n}\n\nfunction recenterLocation(matrix: BitMatrix, p: Point): Point {\n let leftX = Math.round(p.x);\n while (matrix.get(leftX, Math.round(p.y))) {\n leftX--;\n }\n let rightX = Math.round(p.x);\n while (matrix.get(rightX, Math.round(p.y))) {\n rightX++;\n }\n const x = (leftX + rightX) / 2;\n\n let topY = Math.round(p.y);\n while (matrix.get(Math.round(x), topY)) {\n topY--;\n }\n let bottomY = Math.round(p.y);\n while (matrix.get(Math.round(x), bottomY)) {\n bottomY++;\n }\n const y = (topY + bottomY) / 2;\n\n return { x, y };\n}\n\ninterface Quad {\n top: {\n startX: number;\n endX: number;\n y: number;\n };\n bottom: {\n startX: number;\n endX: number;\n y: number;\n };\n}\n\nexport function locate(matrix: BitMatrix): QRLocation[] {\n const finderPatternQuads: Quad[] = [];\n let activeFinderPatternQuads: Quad[] = [];\n const alignmentPatternQuads: Quad[] = [];\n let activeAlignmentPatternQuads: Quad[] = [];\n\n for (let y = 0; y <= matrix.height; y++) {\n let length = 0;\n let lastBit = false;\n let scans = [0, 0, 0, 0, 0];\n\n for (let x = -1; x <= matrix.width; x++) {\n const v = matrix.get(x, y);\n if (v === lastBit) {\n length++;\n } else {\n scans = [scans[1], scans[2], scans[3], scans[4], length];\n length = 1;\n lastBit = v;\n\n // Do the last 5 color changes ~ match the expected ratio for a finder pattern? 1:1:3:1:1 of b:w:b:w:b\n const averageFinderPatternBlocksize = sum(scans) / 7;\n const validFinderPattern =\n Math.abs(scans[0] - averageFinderPatternBlocksize) < averageFinderPatternBlocksize &&\n Math.abs(scans[1] - averageFinderPatternBlocksize) < averageFinderPatternBlocksize &&\n Math.abs(scans[2] - 3 * averageFinderPatternBlocksize) < 3 * averageFinderPatternBlocksize &&\n Math.abs(scans[3] - averageFinderPatternBlocksize) < averageFinderPatternBlocksize &&\n Math.abs(scans[4] - averageFinderPatternBlocksize) < averageFinderPatternBlocksize &&\n !v; // And make sure the current pixel is white since finder patterns are bordered in white\n\n // Do the last 3 color changes ~ match the expected ratio for an alignment pattern? 1:1:1 of w:b:w\n const averageAlignmentPatternBlocksize = sum(scans.slice(-3)) / 3;\n const validAlignmentPattern =\n Math.abs(scans[2] - averageAlignmentPatternBlocksize) < averageAlignmentPatternBlocksize &&\n Math.abs(scans[3] - averageAlignmentPatternBlocksize) < averageAlignmentPatternBlocksize &&\n Math.abs(scans[4] - averageAlignmentPatternBlocksize) < averageAlignmentPatternBlocksize &&\n v; // Is the current pixel black since alignment patterns are bordered in black\n\n if (validFinderPattern) {\n // Compute the start and end x values of the large center black square\n const endX = x - scans[3] - scans[4];\n const startX = endX - scans[2];\n\n const line = { startX, endX, y };\n // Is there a quad directly above the current spot? If so, extend it with the new line. Otherwise, create a new quad with\n // that line as the starting point.\n const matchingQuads = activeFinderPatternQuads.filter(q =>\n (startX >= q.bottom.startX && startX <= q.bottom.endX) ||\n (endX >= q.bottom.startX && startX <= q.bottom.endX) ||\n (startX <= q.bottom.startX && endX >= q.bottom.endX && (\n (scans[2] / (q.bottom.endX - q.bottom.startX)) < MAX_QUAD_RATIO &&\n (scans[2] / (q.bottom.endX - q.bottom.startX)) > MIN_QUAD_RATIO\n )),\n );\n if (matchingQuads.length > 0) {\n matchingQuads[0].bottom = line;\n } else {\n activeFinderPatternQuads.push({ top: line, bottom: line });\n }\n }\n if (validAlignmentPattern) {\n // Compute the start and end x values of the center black square\n const endX = x - scans[4];\n const startX = endX - scans[3];\n\n const line = { startX, y, endX };\n // Is there a quad directly above the current spot? If so, extend it with the new line. Otherwise, create a new quad with\n // that line as the starting point.\n const matchingQuads = activeAlignmentPatternQuads.filter(q =>\n (startX >= q.bottom.startX && startX <= q.bottom.endX) ||\n (endX >= q.bottom.startX && startX <= q.bottom.endX) ||\n (startX <= q.bottom.startX && endX >= q.bottom.endX && (\n (scans[2] / (q.bottom.endX - q.bottom.startX)) < MAX_QUAD_RATIO &&\n (scans[2] / (q.bottom.endX - q.bottom.startX)) > MIN_QUAD_RATIO\n )),\n );\n if (matchingQuads.length > 0) {\n matchingQuads[0].bottom = line;\n } else {\n activeAlignmentPatternQuads.push({ top: line, bottom: line });\n }\n }\n }\n }\n finderPatternQuads.push(...activeFinderPatternQuads.filter(q => q.bottom.y !== y && q.bottom.y - q.top.y >= 2));\n activeFinderPatternQuads = activeFinderPatternQuads.filter(q => q.bottom.y === y);\n\n alignmentPatternQuads.push(...activeAlignmentPatternQuads.filter(q => q.bottom.y !== y));\n activeAlignmentPatternQuads = activeAlignmentPatternQuads.filter(q => q.bottom.y === y);\n\n }\n\n finderPatternQuads.push(...activeFinderPatternQuads.filter(q => q.bottom.y - q.top.y >= 2));\n alignmentPatternQuads.push(...activeAlignmentPatternQuads);\n\n // Refactored from cozmo/jsQR to (hopefully) circumvent an issue in Safari 13+ on both Mac and iOS (also including\n // iOS Chrome and other Safari iOS derivatives). Safari was very occasionally and apparently not deterministically\n // throwing a \"RangeError: Array size is not a small enough positive integer.\" exception seemingly within the second\n // .map of the original code (here the second for-loop). This second .map contained a nested .map call over the same\n // array instance which was the chained result from previous calls to .map, .filter and .sort which potentially caused\n // this bug in Safari?\n // Also see https://github.com/cozmo/jsQR/issues/157 and https://bugs.webkit.org/show_bug.cgi?id=211619#c3\n const scoredFinderPatternPositions: Array = [];\n for (const quad of finderPatternQuads) {\n if (quad.bottom.y - quad.top.y < 2) {\n // All quads must be at least 2px tall since the center square is larger than a block\n continue;\n }\n\n // calculate quad center\n const x = (quad.top.startX + quad.top.endX + quad.bottom.startX + quad.bottom.endX) / 4;\n const y = (quad.top.y + quad.bottom.y + 1) / 2;\n if (!matrix.get(Math.round(x), Math.round(y))) {\n continue;\n }\n\n const lengths = [quad.top.endX - quad.top.startX, quad.bottom.endX - quad.bottom.startX, quad.bottom.y - quad.top.y + 1];\n const size = sum(lengths) / lengths.length;\n // Initial scoring of finder pattern quads by looking at their ratios, not taking into account position\n const score = scorePattern({x: Math.round(x), y: Math.round(y)}, [1, 1, 3, 1, 1], matrix);\n scoredFinderPatternPositions.push({ score, x, y, size });\n }\n if (scoredFinderPatternPositions.length < 3) {\n // A QR code has 3 finder patterns, therefore we need at least 3 candidates.\n return null;\n }\n scoredFinderPatternPositions.sort((a, b) => a.score - b.score);\n\n // Now take the top finder pattern options and try to find 2 other options with a similar size.\n const finderPatternGroups: Array<{ points: [Point, Point, Point], score: number }> = [];\n for (let i = 0; i < Math.min(scoredFinderPatternPositions.length, MAX_FINDERPATTERNS_TO_SEARCH); ++i) {\n const point = scoredFinderPatternPositions[i];\n const otherPoints: typeof scoredFinderPatternPositions = [];\n\n for (const otherPoint of scoredFinderPatternPositions) {\n if (otherPoint === point) {\n continue;\n }\n otherPoints.push({\n ...otherPoint,\n score: otherPoint.score + ((otherPoint.size - point.size) ** 2) / point.size, // score similarity of sizes\n });\n }\n otherPoints.sort((a, b) => a.score - b.score);\n\n finderPatternGroups.push({\n points: [point, otherPoints[0], otherPoints[1]], // note that otherPoints.length >= 2 as scoredFinderPatternPositions.length >= 3\n score: point.score + otherPoints[0].score + otherPoints[1].score, // total combined score of the three points in the group\n });\n }\n finderPatternGroups.sort((a, b) => a.score - b.score);\n const bestFinderPatternGroup = finderPatternGroups[0];\n\n const { topRight, topLeft, bottomLeft } = reorderFinderPatterns(...bestFinderPatternGroup.points);\n const alignment = findAlignmentPattern(matrix, alignmentPatternQuads, topRight, topLeft, bottomLeft);\n const result: QRLocation[] = [];\n if (alignment) {\n result.push({\n alignmentPattern: { x: alignment.alignmentPattern.x, y: alignment.alignmentPattern.y },\n bottomLeft: {x: bottomLeft.x, y: bottomLeft.y },\n dimension: alignment.dimension,\n topLeft: {x: topLeft.x, y: topLeft.y },\n topRight: {x: topRight.x, y: topRight.y },\n });\n }\n\n // We normally use the center of the quads as the location of the tracking points, which is optimal for most cases and will account\n // for a skew in the image. However, In some cases, a slight skew might not be real and instead be caused by image compression\n // errors and/or low resolution. For those cases, we'd be better off centering the point exactly in the middle of the black area. We\n // compute and return the location data for the naively centered points as it is little additional work and allows for multiple\n // attempts at decoding harder images.\n const midTopRight = recenterLocation(matrix, topRight);\n const midTopLeft = recenterLocation(matrix, topLeft);\n const midBottomLeft = recenterLocation(matrix, bottomLeft);\n const centeredAlignment = findAlignmentPattern(matrix, alignmentPatternQuads, midTopRight, midTopLeft, midBottomLeft);\n if (centeredAlignment) {\n result.push({\n alignmentPattern: { x: centeredAlignment.alignmentPattern.x, y: centeredAlignment.alignmentPattern.y },\n bottomLeft: { x: midBottomLeft.x, y: midBottomLeft. y },\n topLeft: { x: midTopLeft.x, y: midTopLeft. y },\n topRight: { x: midTopRight.x, y: midTopRight. y },\n dimension: centeredAlignment.dimension,\n });\n }\n\n if (result.length === 0) {\n return null;\n }\n\n return result;\n}\n\nfunction findAlignmentPattern(matrix: BitMatrix, alignmentPatternQuads: Quad[], topRight: Point, topLeft: Point, bottomLeft: Point) {\n // Now that we've found the three finder patterns we can determine the blockSize and the size of the QR code.\n // We'll use these to help find the alignment pattern but also later when we do the extraction.\n let dimension: number;\n let moduleSize: number;\n try {\n ({ dimension, moduleSize } = computeDimension(topLeft, topRight, bottomLeft, matrix));\n } catch (e) {\n return null;\n }\n\n // Now find the alignment pattern\n const bottomRightFinderPattern = { // Best guess at where a bottomRight finder pattern would be\n x: topRight.x - topLeft.x + bottomLeft.x,\n y: topRight.y - topLeft.y + bottomLeft.y,\n };\n const modulesBetweenFinderPatterns = ((distance(topLeft, bottomLeft) + distance(topLeft, topRight)) / 2 / moduleSize);\n const correctionToTopLeft = 1 - (3 / modulesBetweenFinderPatterns);\n const expectedAlignmentPattern = {\n x: topLeft.x + correctionToTopLeft * (bottomRightFinderPattern.x - topLeft.x),\n y: topLeft.y + correctionToTopLeft * (bottomRightFinderPattern.y - topLeft.y),\n };\n\n const alignmentPatterns = alignmentPatternQuads\n .map(q => {\n const x = (q.top.startX + q.top.endX + q.bottom.startX + q.bottom.endX) / 4;\n const y = (q.top.y + q.bottom.y + 1) / 2;\n if (!matrix.get(Math.floor(x), Math.floor(y))) {\n return;\n }\n\n const sizeScore = scorePattern({x: Math.floor(x), y: Math.floor(y)}, [1, 1, 1], matrix);\n const score = sizeScore + distance({x, y}, expectedAlignmentPattern);\n return { x, y, score };\n })\n .filter(v => !!v)\n .sort((a, b) => a.score - b.score);\n\n // If there are less than 15 modules between finder patterns it's a version 1 QR code and as such has no alignmemnt pattern\n // so we can only use our best guess.\n const alignmentPattern = modulesBetweenFinderPatterns >= 15 && alignmentPatterns.length ? alignmentPatterns[0] : expectedAlignmentPattern;\n\n return { alignmentPattern, dimension };\n}\n", "import {binarize} from \"./binarizer\";\nimport {BitMatrix} from \"./BitMatrix\";\nimport {Chunks} from \"./decoder/decodeData\";\nimport {decode} from \"./decoder/decoder\";\nimport { Version } from \"./decoder/version\";\nimport {extract} from \"./extractor\";\nimport {locate, Point} from \"./locator\";\n\nexport interface QRCode {\n binaryData: number[];\n data: string;\n chunks: Chunks;\n version: number;\n location: {\n topRightCorner: Point;\n topLeftCorner: Point;\n bottomRightCorner: Point;\n bottomLeftCorner: Point;\n\n topRightFinderPattern: Point;\n topLeftFinderPattern: Point;\n bottomLeftFinderPattern: Point;\n\n bottomRightAlignmentPattern?: Point;\n };\n matrix: BitMatrix;\n}\n\nfunction scan(matrix: BitMatrix): QRCode | null {\n const locations = locate(matrix);\n if (!locations) {\n return null;\n }\n\n for (const location of locations) {\n const extracted = extract(matrix, location);\n const decoded = decode(extracted.matrix);\n if (decoded) {\n return {\n binaryData: decoded.bytes,\n data: decoded.text,\n chunks: decoded.chunks,\n version: decoded.version,\n location: {\n topRightCorner: extracted.mappingFunction(location.dimension, 0),\n topLeftCorner: extracted.mappingFunction(0, 0),\n bottomRightCorner: extracted.mappingFunction(location.dimension, location.dimension),\n bottomLeftCorner: extracted.mappingFunction(0, location.dimension),\n\n topRightFinderPattern: location.topRight,\n topLeftFinderPattern: location.topLeft,\n bottomLeftFinderPattern: location.bottomLeft,\n\n bottomRightAlignmentPattern: location.alignmentPattern,\n },\n matrix: extracted.matrix,\n };\n }\n }\n return null;\n}\n\nexport interface Options {\n inversionAttempts?: \"dontInvert\" | \"onlyInvert\" | \"attemptBoth\" | \"invertFirst\";\n greyScaleWeights?: GreyscaleWeights;\n canOverwriteImage?: boolean;\n}\n\nexport interface GreyscaleWeights {\n red: number;\n green: number;\n blue: number;\n useIntegerApproximation?: boolean;\n}\n\nconst defaultOptions: Options = {\n inversionAttempts: \"attemptBoth\",\n greyScaleWeights: {\n red: 0.2126,\n green: 0.7152,\n blue: 0.0722,\n useIntegerApproximation: false,\n },\n canOverwriteImage: true,\n};\n\nfunction mergeObject(target: any, src: any) {\n Object.keys(src).forEach(opt => { // Sad implementation of Object.assign since we target es5 not es6\n target[opt] = src[opt];\n });\n}\n\nfunction jsQR(data: Uint8ClampedArray, width: number, height: number, providedOptions: Options = {}): QRCode | null {\n const options = Object.create(null);\n mergeObject(options, defaultOptions);\n mergeObject(options, providedOptions);\n\n const tryInvertedFirst = options.inversionAttempts === \"onlyInvert\" || options.inversionAttempts === \"invertFirst\";\n const shouldInvert = options.inversionAttempts === \"attemptBoth\" || tryInvertedFirst;\n const {binarized, inverted} = binarize(data, width, height, shouldInvert, options.greyScaleWeights,\n options.canOverwriteImage);\n let result = scan(tryInvertedFirst ? inverted : binarized);\n if (!result && (options.inversionAttempts === \"attemptBoth\" || options.inversionAttempts === \"invertFirst\")) {\n result = scan(tryInvertedFirst ? binarized : inverted);\n }\n return result;\n}\n\n(jsQR as any).default = jsQR;\nexport default jsQR;\n", "// @ts-ignore jsqr-es6 does not provide types currently\nimport jsQR from '../node_modules/jsqr-es6/dist/jsQR.js';\n\ntype GrayscaleWeights = {\n red: number,\n green: number,\n blue: number,\n useIntegerApproximation: boolean,\n};\n\nlet inversionAttempts: 'dontInvert' | 'onlyInvert' | 'attemptBoth' = 'dontInvert';\nlet grayscaleWeights: GrayscaleWeights = {\n // weights for quick luma integer approximation (https://en.wikipedia.org/wiki/YUV#Full_swing_for_BT.601)\n red: 77,\n green: 150,\n blue: 29,\n useIntegerApproximation: true,\n};\n\nself.onmessage = event => {\n const id = event['data']['id'];\n const type = event['data']['type'];\n const data = event['data']['data'];\n\n switch (type) {\n case 'decode':\n decode(data, id);\n break;\n case 'grayscaleWeights':\n setGrayscaleWeights(data);\n break;\n case 'inversionMode':\n setInversionMode(data);\n break;\n case 'close':\n // close after earlier messages in the event loop finished processing\n self.close();\n break;\n }\n};\n\nfunction decode(data: { data: Uint8ClampedArray, width: number, height: number }, requestId: number): void {\n const rgbaData = data['data'];\n const width = data['width'];\n const height = data['height'];\n const result = jsQR(rgbaData, width, height, {\n inversionAttempts: inversionAttempts,\n greyScaleWeights: grayscaleWeights,\n });\n if (!result) {\n (self as unknown as Worker).postMessage({\n id: requestId,\n type: 'qrResult',\n data: null,\n });\n return;\n }\n\n (self as unknown as Worker).postMessage({\n id: requestId,\n type: 'qrResult',\n data: result.data,\n // equivalent to cornerPoints of native BarcodeDetector\n cornerPoints: [\n result.location.topLeftCorner,\n result.location.topRightCorner,\n result.location.bottomRightCorner,\n result.location.bottomLeftCorner,\n ],\n });\n}\n\nfunction setGrayscaleWeights(data: GrayscaleWeights) {\n // update grayscaleWeights in a closure compiler compatible fashion\n grayscaleWeights.red = data['red'];\n grayscaleWeights.green = data['green'];\n grayscaleWeights.blue = data['blue'];\n grayscaleWeights.useIntegerApproximation = data['useIntegerApproximation'];\n}\n\nfunction setInversionMode(inversionMode: 'original' | 'invert' | 'both') {\n switch (inversionMode) {\n case 'original':\n inversionAttempts = 'dontInvert';\n break;\n case 'invert':\n inversionAttempts = 'onlyInvert';\n break;\n case 'both':\n inversionAttempts = 'attemptBoth';\n break;\n default:\n throw new Error('Invalid inversion mode');\n }\n}\n", "up.compiler('[readonly-checkboxes]', (element) => {\n up.on(element, 'change', 'input[type=\"checkbox\"]', (event) => {\n event.target.checked = !event.target.checked\n })\n})\n", "up.compiler('[scale-to-fill-container]', (element) => {\n function isOverflown(parent) {\n const overflowWidth = element.clientWidth > parent.clientWidth\n const overflowHeight = element.clientHeight > parent.clientHeight\n return overflowHeight || overflowWidth\n }\n\n function resizeText() {\n const parent = element.parentElement\n const step = 1\n let i = 5\n\n while (i < 50) {\n setFontSize(i)\n if (isOverflown(parent)) {\n i -= step // revert to last state where no overflow happened\n break\n }\n\n i += step\n }\n\n setFontSize(i)\n }\n\n function setFontSize(fontSize) {\n element.style.fontSize = `${fontSize}px`\n }\n\n resizeText()\n\n element.addEventListener('text:resizeThis', resizeText)\n\n return up.on(window, 'resize', resizeText)\n})\n\nup.on('text:resize', ({ target }) => {\n const scalableElement = target.querySelector('[scale-to-fill-container]')\n if (scalableElement) {\n up.emit(scalableElement, 'text:resizeThis')\n }\n})\n", "up.compiler('[scrollable-pagination]', (element) => {\n const focusedButton = element.querySelector('[scrollable-pagination--focused = true]')\n const xOffset = focusedButton.getBoundingClientRect().left\n const paginationWidth = element.offsetWidth\n\n element.scroll(xOffset - (paginationWidth / 2), 0)\n})\n", "if ('serviceWorker' in navigator) {\n navigator.serviceWorker.register('/service-worker.js', { scope: '/' })\n}\n", "up.on('up:form:submit', '.slide-form', ({ renderOptions }) => {\n renderOptions.onLoaded = function({ response }) {\n if (response.header('X-Course-Completed')) {\n renderOptions.transition = 'none'\n }\n }\n})\n", "/******/ (() => { // webpackBootstrap\n/******/ \tvar __webpack_modules__ = ([\n/* 0 */,\n/* 1 */\n/***/ (() => {\n\nwindow.up = {\n version: '3.7.3'\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (() => {\n\nup.mockable = function (originalFn) {\n if (window.jasmine) {\n let name = originalFn.name;\n let obj = { [name]: originalFn };\n let mockableFn = function () {\n return obj[name].apply(this, arguments);\n };\n mockableFn.mock = () => spyOn(obj, name);\n return mockableFn;\n }\n else {\n return originalFn;\n }\n};\n\n\n/***/ }),\n/* 3 */\n/***/ (() => {\n\nup.util = (function () {\n function noop() {\n }\n function asyncNoop() {\n return Promise.resolve();\n }\n function memoize(func) {\n let cachedValue, cached;\n return function (...args) {\n if (cached) {\n return cachedValue;\n }\n else {\n cached = true;\n return cachedValue = func.apply(this, args);\n }\n };\n }\n const NORMALIZE_URL_DEFAULTS = {\n host: 'cross-domain',\n };\n function normalizeURL(url, options) {\n options = newOptions(options, NORMALIZE_URL_DEFAULTS);\n const parts = parseURL(url);\n let normalized = '';\n if (options.host === 'cross-domain') {\n options.host = isCrossOrigin(parts);\n }\n if (options.host) {\n normalized += parts.protocol + \"//\" + parts.host;\n }\n let { pathname } = parts;\n if (options.trailingSlash === false && pathname !== '/') {\n pathname = pathname.replace(/\\/$/, '');\n }\n normalized += pathname;\n if (options.search !== false) {\n normalized += parts.search;\n }\n if (options.hash !== false) {\n normalized += parts.hash;\n }\n return normalized;\n }\n function matchURLs(leftURL, rightURL) {\n return normalizeURL(leftURL) === normalizeURL(rightURL);\n }\n const APP_PROTOCOL = location.protocol;\n const APP_HOSTNAME = location.hostname;\n function isCrossOrigin(urlOrAnchor) {\n if (isString(urlOrAnchor) && (urlOrAnchor.indexOf('//') === -1)) {\n return false;\n }\n const parts = parseURL(urlOrAnchor);\n return (APP_HOSTNAME !== parts.hostname) || (APP_PROTOCOL !== parts.protocol);\n }\n function parseURL(url) {\n if (url.pathname) {\n return url;\n }\n let link = document.createElement('a');\n link.href = url;\n return link;\n }\n function normalizeMethod(method) {\n return method ? method.toUpperCase() : 'GET';\n }\n function methodAllowsPayload(method) {\n return (method !== 'GET') && (method !== 'HEAD');\n }\n function iteratee(block) {\n if (isString(block)) {\n return item => item[block];\n }\n else {\n return block;\n }\n }\n function map(list, block) {\n if (list.length === 0) {\n return [];\n }\n block = iteratee(block);\n let mapped = [];\n let i = 0;\n for (let item of list) {\n mapped.push(block(item, i++));\n }\n return mapped;\n }\n function mapObject(array, pairer) {\n const merger = function (object, pair) {\n object[pair[0]] = pair[1];\n return object;\n };\n return map(array, pairer).reduce(merger, {});\n }\n function each(array, block) {\n let i = 0;\n for (let item of array) {\n block(item, i++);\n }\n }\n function isNull(object) {\n return object === null;\n }\n function isUndefined(object) {\n return object === undefined;\n }\n const isDefined = negate(isUndefined);\n function isMissing(object) {\n return isUndefined(object) || isNull(object);\n }\n const isGiven = negate(isMissing);\n function isBlank(value) {\n if (isMissing(value)) {\n return true;\n }\n if (isObject(value) && value[isBlank.key]) {\n return value[isBlank.key]();\n }\n if (isString(value) || isList(value)) {\n return value.length === 0;\n }\n if (isOptions(value)) {\n return Object.keys(value).length === 0;\n }\n return false;\n }\n isBlank.key = 'up.util.isBlank';\n function presence(value, tester = isPresent) {\n if (tester(value)) {\n return value;\n }\n }\n const isPresent = negate(isBlank);\n function isFunction(object) {\n return typeof (object) === 'function';\n }\n function isString(object) {\n return (typeof (object) === 'string') || object instanceof String;\n }\n function isBoolean(object) {\n return (typeof (object) === 'boolean') || object instanceof Boolean;\n }\n function isNumber(object) {\n return (typeof (object) === 'number') || object instanceof Number;\n }\n function isOptions(object) {\n return (typeof (object) === 'object') && !isNull(object) && (isUndefined(object.constructor) || (object.constructor === Object));\n }\n function isObject(object) {\n const typeOfResult = typeof (object);\n return ((typeOfResult === 'object') && !isNull(object)) || (typeOfResult === 'function');\n }\n function isElement(object) {\n return object instanceof Element;\n }\n function isRegExp(object) {\n return object instanceof RegExp;\n }\n function isError(object) {\n return object instanceof Error;\n }\n function isJQuery(object) {\n return up.browser.canJQuery() && object instanceof jQuery;\n }\n function isElementish(object) {\n return !!(object && (object.addEventListener || object[0]?.addEventListener));\n }\n function isPromise(object) {\n return isObject(object) && isFunction(object.then);\n }\n const { isArray } = Array;\n function isFormData(object) {\n return object instanceof FormData;\n }\n function toArray(value) {\n return isArray(value) ? value : copyArrayLike(value);\n }\n function isList(value) {\n return isArray(value) ||\n isNodeList(value) ||\n isArguments(value) ||\n isJQuery(value) ||\n isHTMLCollection(value);\n }\n function isNodeList(value) {\n return value instanceof NodeList;\n }\n function isHTMLCollection(value) {\n return value instanceof HTMLCollection;\n }\n function isArguments(value) {\n return Object.prototype.toString.call(value) === '[object Arguments]';\n }\n function nullToUndefined(value) {\n if (!isNull(value)) {\n return value;\n }\n }\n function wrapList(value) {\n if (isList(value)) {\n return value;\n }\n else if (isMissing(value)) {\n return [];\n }\n else {\n return [value];\n }\n }\n function copy(value) {\n if (isObject(value) && value[copy.key]) {\n value = value[copy.key]();\n }\n else if (isList(value)) {\n value = copyArrayLike(value);\n }\n else if (isOptions(value)) {\n value = Object.assign({}, value);\n }\n return value;\n }\n function copyArrayLike(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n }\n copy.key = 'up.util.copy';\n Date.prototype[copy.key] = function () { return new Date(+this); };\n function merge(...sources) {\n return Object.assign({}, ...sources);\n }\n function mergeDefined(...sources) {\n const result = {};\n for (let source of sources) {\n if (source) {\n for (let key in source) {\n const value = source[key];\n if (isDefined(value)) {\n result[key] = value;\n }\n }\n }\n }\n return result;\n }\n function newOptions(object, defaults) {\n if (defaults) {\n return merge(defaults, object);\n }\n else if (object) {\n return copy(object);\n }\n else {\n return {};\n }\n }\n function parseArgIntoOptions(args, argKey) {\n let options = extractOptions(args);\n if (isDefined(args[0])) {\n options = copy(options);\n options[argKey] = args[0];\n }\n return options;\n }\n function findInList(list, tester) {\n tester = iteratee(tester);\n let match;\n for (let element of list) {\n if (tester(element)) {\n match = element;\n break;\n }\n }\n return match;\n }\n function some(list, tester) {\n return !!findResult(list, tester);\n }\n function findResult(list, tester) {\n tester = iteratee(tester);\n let i = 0;\n for (let item of list) {\n const result = tester(item, i++);\n if (result) {\n return result;\n }\n }\n }\n function every(list, tester) {\n tester = iteratee(tester);\n let match = true;\n let i = 0;\n for (let item of list) {\n if (!tester(item, i++)) {\n match = false;\n break;\n }\n }\n return match;\n }\n function compact(array) {\n return filterList(array, isGiven);\n }\n function filterMap(list, mapping) {\n return filterList(map(list, mapping), isDefined);\n }\n function compactObject(object) {\n return pickBy(object, isGiven);\n }\n function uniq(array) {\n if (array.length < 2) {\n return array;\n }\n return Array.from(new Set(array));\n }\n function uniqBy(array, mapper) {\n if (array.length < 2) {\n return array;\n }\n mapper = iteratee(mapper);\n const seenElements = new Set();\n return filterList(array, function (elem, index) {\n const mapped = mapper(elem, index);\n if (seenElements.has(mapped)) {\n return false;\n }\n else {\n seenElements.add(mapped);\n return true;\n }\n });\n }\n function filterList(list, tester) {\n tester = iteratee(tester);\n const matches = [];\n each(list, function (element, index) {\n if (tester(element, index)) {\n return matches.push(element);\n }\n });\n return matches;\n }\n function reject(list, tester) {\n tester = negate(iteratee(tester));\n return filterList(list, tester);\n }\n function intersect(array1, array2) {\n return filterList(array1, element => contains(array2, element));\n }\n function scheduleTimer(millis, callback) {\n return setTimeout(callback, millis);\n }\n function queueTask(task) {\n return setTimeout(task);\n }\n function queueMicrotask(task) {\n return Promise.resolve().then(task);\n }\n function last(value) {\n return value[value.length - 1];\n }\n function contains(value, subValue) {\n let indexOf = value.indexOf || Array.prototype.indexOf;\n return indexOf.call(value, subValue) >= 0;\n }\n function objectContains(object, subObject) {\n const reducedValue = pick(object, Object.keys(subObject));\n return isEqual(subObject, reducedValue);\n }\n function pick(object, keys) {\n const filtered = {};\n for (let key of keys) {\n if (key in object) {\n filtered[key] = object[key];\n }\n }\n return filtered;\n }\n function pickBy(object, tester) {\n tester = iteratee(tester);\n const filtered = {};\n for (let key in object) {\n const value = object[key];\n if (tester(value, key, object)) {\n filtered[key] = object[key];\n }\n }\n return filtered;\n }\n function omit(object, keys) {\n return pickBy(object, (_value, key) => !contains(keys, key));\n }\n function unresolvablePromise() {\n return new Promise(noop);\n }\n function remove(array, element) {\n const index = array.indexOf(element);\n if (index >= 0) {\n array.splice(index, 1);\n return element;\n }\n }\n function evalOption(value, ...args) {\n return isFunction(value) ? value(...args) : value;\n }\n function evalAutoOption(value, autoMeans, ...args) {\n value = evalOption(value, ...args);\n if (value === 'auto') {\n value = evalOption(autoMeans, ...args);\n }\n return value;\n }\n const ESCAPE_HTML_ENTITY_MAP = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': '"',\n \"'\": '''\n };\n function escapeHTML(string) {\n return string.replace(/[&<>\"']/g, char => ESCAPE_HTML_ENTITY_MAP[char]);\n }\n function escapeRegExp(string) {\n return string.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n }\n function pluckKey(object, key) {\n const value = object[key];\n delete object[key];\n return value;\n }\n function renameKey(object, oldKey, newKey) {\n return object[newKey] = pluckKey(object, oldKey);\n }\n function extractLastArg(args, tester) {\n if (tester(last(args))) {\n return args.pop();\n }\n }\n function extractCallback(args) {\n return extractLastArg(args, isFunction);\n }\n function extractOptions(args) {\n return extractLastArg(args, isOptions) || {};\n }\n function identity(arg) {\n return arg;\n }\n function sequence(functions) {\n functions = compact(functions);\n return (...args) => map(functions, fn => fn(...args));\n }\n function flatten(array) {\n const flattened = [];\n for (let object of array) {\n if (isList(object)) {\n flattened.push(...object);\n }\n else {\n flattened.push(object);\n }\n }\n return flattened;\n }\n function flatMap(array, block) {\n return flatten(map(array, block));\n }\n function always(promise, callback = identity) {\n return promise.then(callback, callback);\n }\n function newDeferred() {\n let resolveFn;\n let rejectFn;\n const nativePromise = new Promise(function (givenResolve, givenReject) {\n resolveFn = givenResolve;\n rejectFn = givenReject;\n });\n nativePromise.resolve = resolveFn;\n nativePromise.reject = rejectFn;\n return nativePromise;\n }\n function isBasicObjectProperty(k) {\n return Object.prototype.hasOwnProperty(k);\n }\n function isEqual(a, b) {\n if (a?.valueOf) {\n a = a.valueOf();\n }\n if (b?.valueOf) {\n b = b.valueOf();\n }\n if (typeof (a) !== typeof (b)) {\n return false;\n }\n else if (isList(a) && isList(b)) {\n return isEqualList(a, b);\n }\n else if (isObject(a) && a[isEqual.key]) {\n return a[isEqual.key](b);\n }\n else if (isOptions(a) && isOptions(b)) {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (isEqualList(aKeys, bKeys)) {\n return every(aKeys, aKey => isEqual(a[aKey], b[aKey]));\n }\n else {\n return false;\n }\n }\n else {\n return a === b;\n }\n }\n isEqual.key = 'up.util.isEqual';\n function isEqualList(a, b) {\n return (a.length === b.length) && every(a, (elem, index) => isEqual(elem, b[index]));\n }\n const PARSE_TOKEN_PATTERNS = {\n 'space/or': /\\s+(?:or\\s+)?/,\n 'or': /\\s+or\\s+/,\n 'comma': /\\s*,\\s*/\n };\n function parseTokens(value, options = {}) {\n if (isString(value)) {\n value = value.trim();\n if (options.json && /^\\[.*]$/.test(value)) {\n return JSON.parse(value);\n }\n else {\n let separator = options.separator || 'space/or';\n let pattern = PARSE_TOKEN_PATTERNS[separator];\n return value.split(pattern);\n }\n }\n else {\n return wrapList(value);\n }\n }\n function wrapValue(constructor, ...args) {\n return (args[0] instanceof constructor) ? args[0] : new constructor(...args);\n }\n let nextUid = 0;\n function uid() {\n return nextUid++;\n }\n function reverse(list) {\n return copy(list).reverse();\n }\n function renameKeys(object, renameKeyFn) {\n const renamed = {};\n for (let key in object) {\n renamed[renameKeyFn(key)] = object[key];\n }\n return renamed;\n }\n function camelToKebabCase(str) {\n return str.replace(/[A-Z]/g, char => '-' + char.toLowerCase());\n }\n function lowerCaseFirst(str) {\n return str[0].toLowerCase() + str.slice(1);\n }\n function upperCaseFirst(str) {\n return str[0].toUpperCase() + str.slice(1);\n }\n function defineDelegates(object, props, targetProvider) {\n for (let prop of props) {\n Object.defineProperty(object, prop, {\n get() {\n const target = targetProvider.call(this);\n let value = target[prop];\n if (isFunction(value)) {\n value = value.bind(target);\n }\n return value;\n },\n set(newValue) {\n const target = targetProvider.call(this);\n target[prop] = newValue;\n }\n });\n }\n }\n function stringifyArg(arg, placeholder = '%o') {\n let string;\n const maxLength = 200;\n if (placeholder === '%c') {\n return '';\n }\n if (placeholder === '%s' && isGiven(arg)) {\n arg = arg.toString();\n }\n if (isString(arg)) {\n string = arg.trim().replace(/[\\n\\r\\t ]+/g, ' ');\n if (placeholder === '%o') {\n string = JSON.stringify(string);\n }\n }\n else if (isUndefined(arg)) {\n string = 'undefined';\n }\n else if (isNumber(arg) || isFunction(arg)) {\n string = arg.toString();\n }\n else if (isArray(arg)) {\n string = `[${map(arg, stringifyArg).join(', ')}]`;\n }\n else if (isJQuery(arg)) {\n string = `$(${map(arg, stringifyArg).join(', ')})`;\n }\n else if (isElement(arg)) {\n string = `<${arg.tagName.toLowerCase()}`;\n for (let attr of ['id', 'up-id', 'name', 'class']) {\n let value = arg.getAttribute(attr);\n if (value) {\n string += ` ${attr}=\"${value}\"`;\n }\n }\n string += \">\";\n }\n else if (isRegExp(arg) || isError(arg)) {\n string = arg.toString();\n }\n else {\n try {\n string = JSON.stringify(arg);\n }\n catch (error) {\n if (error.name === 'TypeError') {\n string = '(circular structure)';\n }\n else {\n throw error;\n }\n }\n }\n if (string.length > maxLength) {\n string = `${string.substr(0, maxLength)}\u2026${last(string)}`;\n }\n return string;\n }\n const SPRINTF_PLACEHOLDERS = /%[oOdisfc]/g;\n function sprintf(message, ...args) {\n return message.replace(SPRINTF_PLACEHOLDERS, (placeholder) => stringifyArg(args.shift(), placeholder));\n }\n function negate(fn) {\n return function (...args) {\n return !fn(...args);\n };\n }\n function useMemoizeCacheEntry(cacheEntry) {\n if (cacheEntry.error) {\n throw cacheEntry.error;\n }\n else {\n return cacheEntry.value;\n }\n }\n function buildMemoizeCacheEntry(oldImpl, self, args) {\n try {\n return { value: oldImpl.apply(self, args) };\n }\n catch (e) {\n return { error: e };\n }\n }\n function memoizeMethod(object, propLiteral) {\n for (let prop in propLiteral) {\n let originalDescriptor = Object.getOwnPropertyDescriptor(object, prop);\n let oldImpl = originalDescriptor.value;\n let cachingImpl = function (...args) {\n let cache = this[`__${prop}MemoizeCache`] ||= {};\n let cacheKey = JSON.stringify(args);\n cache[cacheKey] ||= buildMemoizeCacheEntry(oldImpl, this, args);\n return useMemoizeCacheEntry(cache[cacheKey]);\n };\n object[prop] = cachingImpl;\n }\n }\n function safeStringifyJSON(value) {\n let json = JSON.stringify(value);\n return escapeHighASCII(json);\n }\n function escapeHighASCII(string) {\n let unicodeEscape = (char) => \"\\\\u\" + char.charCodeAt(0).toString(16).padStart(4, '0');\n return string.replace(/[^\\x00-\\x7F]/g, unicodeEscape);\n }\n function variant(source, changes = {}) {\n let variant = Object.create(source);\n Object.assign(variant, changes);\n return variant;\n }\n return {\n parseURL,\n normalizeURL,\n matchURLs,\n normalizeMethod,\n methodAllowsPayload,\n copy,\n copyArrayLike,\n merge,\n mergeDefined,\n options: newOptions,\n parseArgIntoOptions,\n each,\n map,\n flatMap,\n mapObject,\n findResult,\n some,\n every,\n find: findInList,\n filter: filterList,\n filterMap: filterMap,\n reject,\n intersect,\n compact,\n compactObject,\n uniq,\n uniqBy,\n last,\n isNull,\n isDefined,\n isUndefined,\n isGiven,\n isMissing,\n isPresent,\n isBlank,\n presence,\n isObject,\n isFunction,\n isString,\n isBoolean,\n isNumber,\n isElement,\n isJQuery,\n isElementish,\n isPromise,\n isOptions,\n isArray,\n isFormData,\n isList,\n isRegExp,\n timer: scheduleTimer,\n contains,\n objectContains,\n toArray,\n pick,\n pickBy,\n omit,\n unresolvablePromise,\n remove,\n memoize,\n pluckKey,\n renameKey,\n extractOptions,\n extractCallback,\n noop,\n asyncNoop,\n identity,\n escapeHTML,\n escapeRegExp,\n sequence,\n evalOption,\n evalAutoOption,\n flatten,\n newDeferred,\n always,\n isBasicObjectProperty,\n isCrossOrigin,\n task: queueTask,\n microtask: queueMicrotask,\n isEqual,\n parseTokens,\n wrapList,\n wrapValue,\n uid,\n upperCaseFirst,\n lowerCaseFirst,\n delegate: defineDelegates,\n reverse,\n camelToKebabCase,\n nullToUndefined,\n sprintf,\n renameKeys,\n negate,\n memoizeMethod,\n safeStringifyJSON,\n variant,\n };\n})();\n\n\n/***/ }),\n/* 4 */\n/***/ (() => {\n\nup.error = (function () {\n function fail(...args) {\n throw new up.Error(args);\n }\n function isCritical(error) {\n return (typeof error !== 'object') || ((error.name !== 'AbortError') && !(error instanceof up.RenderResult) && !(error instanceof up.Response));\n }\n function muteUncriticalRejection(promise) {\n return promise.catch(throwCritical);\n }\n function muteUncriticalSync(block) {\n try {\n return block();\n }\n catch (e) {\n throwCritical(e);\n }\n }\n function throwCritical(value) {\n if (isCritical(value)) {\n throw value;\n }\n }\n function report(error) {\n console.error('Uncaught %o', error);\n let event = new ErrorEvent('error', { error, message: 'Uncaught ' + error });\n window.dispatchEvent(event);\n }\n function guard(fn) {\n try {\n return fn();\n }\n catch (error) {\n report(error);\n }\n }\n function guardFn(fn) {\n return (...args) => guard(() => fn(...args));\n }\n return {\n fail,\n throwCritical,\n muteUncriticalRejection,\n muteUncriticalSync,\n guard,\n guardFn,\n };\n})();\nup.fail = up.error.fail;\n\n\n/***/ }),\n/* 5 */\n/***/ (() => {\n\nup.migrate = { config: {} };\n\n\n/***/ }),\n/* 6 */\n/***/ (() => {\n\nup.browser = (function () {\n const u = up.util;\n function submitForm(form) {\n form.submit();\n }\n function canPushState() {\n return up.protocol.initialRequestMethod() === 'GET';\n }\n function canJQuery() {\n return !!window.jQuery;\n }\n const canHasSelector = u.memoize(() => CSS.supports('selector(:has(*))'));\n function popCookie(name) {\n let value = document.cookie.match(new RegExp(name + \"=(\\\\w+)\"))?.[1];\n if (value) {\n document.cookie = name + '=;Max-Age=0;Path=/';\n return value;\n }\n }\n function assertConfirmed(options) {\n const confirmed = !options.confirm || window.confirm(options.confirm);\n if (!confirmed) {\n throw new up.Aborted('User canceled action');\n }\n return true;\n }\n return {\n submitForm,\n canPushState,\n canJQuery,\n assertConfirmed,\n popCookie,\n canHasSelector,\n };\n})();\n\n\n/***/ }),\n/* 7 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(8);\nup.element = (function () {\n const u = up.util;\n function first(...args) {\n const selector = args.pop();\n const root = args[0] || document;\n return root.querySelector(selector);\n }\n function subtree(root, selector) {\n const results = [];\n if (root.matches(selector)) {\n results.push(root);\n }\n results.push(...root.querySelectorAll(selector));\n return results;\n }\n function contains(root, selectorOrElement) {\n const element = getOne(selectorOrElement);\n return Node.prototype.contains.call(root, element);\n }\n function ancestor(element, selector) {\n return element.parentNode?.closest(selector);\n }\n function around(element, selector) {\n return getList(element.closest(selector), subtree(element, selector));\n }\n function getOne(...args) {\n const value = args.pop();\n if (u.isElement(value)) {\n return value;\n }\n else if (u.isString(value)) {\n return first(...args, value);\n }\n else if (u.isList(value)) {\n if (value.length > 1) {\n up.fail('up.element.get(): Cannot cast multiple elements (%o) to a single element', value);\n }\n return value[0];\n }\n else {\n return value;\n }\n }\n function getList(...args) {\n return u.flatMap(args, valueToList);\n }\n function valueToList(value) {\n if (u.isString(value)) {\n return document.querySelectorAll(value);\n }\n else {\n return u.wrapList(value);\n }\n }\n function hide(element) {\n element.setAttribute('hidden', '');\n }\n function show(element) {\n element.removeAttribute('hidden');\n if (element.style.display === 'none') {\n element.style.display = '';\n }\n }\n function toggle(element, newVisible) {\n if (newVisible == null) {\n newVisible = !isVisible(element);\n }\n (newVisible ? show : hide)(element);\n }\n function toggleAttr(element, attr, value, newPresent) {\n if (newPresent == null) {\n newPresent = !element.hasAttribute(attr);\n }\n if (newPresent) {\n return element.setAttribute(attr, value);\n }\n else {\n return element.removeAttribute(attr);\n }\n }\n function setAttrs(element, attrs) {\n for (let key in attrs) {\n const value = attrs[key];\n if (u.isGiven(value)) {\n element.setAttribute(key, value);\n }\n else {\n element.removeAttribute(key);\n }\n }\n }\n function setTemporaryAttrs(element, attrs) {\n const oldAttrs = {};\n for (let key of Object.keys(attrs)) {\n oldAttrs[key] = element.getAttribute(key);\n }\n setAttrs(element, attrs);\n return () => setAttrs(element, oldAttrs);\n }\n function metaContent(name) {\n const selector = \"meta\" + attrSelector('name', name);\n return first(selector)?.getAttribute('content');\n }\n function insertBefore(existingElement, newElement) {\n existingElement.insertAdjacentElement('beforebegin', newElement);\n }\n function createFromSelector(selector, attrs = {}) {\n let { includePath } = parseSelector(selector);\n let rootElement;\n let depthElement;\n let previousElement;\n for (let includeSegment of includePath) {\n let { tagName, id, classNames, attributes } = includeSegment;\n if (!tagName || tagName === '*') {\n tagName = 'div';\n }\n depthElement = document.createElement(tagName);\n if (!rootElement) {\n rootElement = depthElement;\n }\n if (id) {\n depthElement.id = id;\n }\n for (let className of classNames) {\n depthElement.classList.add(className);\n }\n for (let attributeName in attributes) {\n let attributeValue = attributes[attributeName];\n depthElement.setAttribute(attributeName, attributeValue || '');\n }\n previousElement?.appendChild(depthElement);\n previousElement = depthElement;\n }\n for (let key in attrs) {\n let value = attrs[key];\n if (key === 'class') {\n for (let klass of u.wrapList(value)) {\n rootElement.classList.add(klass);\n }\n }\n else if (key === 'style') {\n setInlineStyle(rootElement, value);\n }\n else if (key === 'text') {\n rootElement.textContent = value;\n }\n else if (key === 'content') {\n rootElement.innerHTML = value;\n }\n else {\n rootElement.setAttribute(key, value);\n }\n }\n return rootElement;\n }\n function parseSelector(selector) {\n let excludeRaw;\n const includeRaw = selector.replace(/:not\\([^)]+\\)/, function (match) {\n excludeRaw = match;\n return '';\n });\n const [includeSelectorWithoutAttrValues, attrValues] = removeAttrSelectorValues(includeRaw);\n const includeSegments = includeSelectorWithoutAttrValues.split(/[ >]+/);\n let includePath = includeSegments.map(function (depthSelector) {\n let parsed = {\n tagName: null,\n classNames: [],\n id: null,\n attributes: {}\n };\n depthSelector = depthSelector.replace(/^[\\w-*]+/, function (match) {\n parsed.tagName = match;\n return '';\n });\n depthSelector = depthSelector.replace(/#([\\w-]+)/, function (_match, id) {\n parsed.id = id;\n return '';\n });\n depthSelector = depthSelector.replace(/\\.([\\w-]+)/g, function (_match, className) {\n parsed.classNames.push(className);\n return '';\n });\n if (attrValues.length) {\n depthSelector = replaceAttrSelectors(depthSelector, function ({ name }) {\n parsed.attributes[name] = attrValues.shift();\n return '';\n });\n }\n if (depthSelector) {\n up.fail('Cannot parse selector: ' + selector);\n }\n return parsed;\n });\n return {\n includePath,\n includeRaw,\n excludeRaw,\n };\n }\n const ATTR_SELECTOR_PATTERN = /\\[([\\w-]+)(?:([~|^$*]?=)([\"'])?([^\\3\\]]*?)\\3)?]/g;\n function replaceAttrSelectors(string, replacement) {\n return string.replace(ATTR_SELECTOR_PATTERN, function (_match, name, operator, quote, value) {\n if (value) {\n value = value.replace(/\\\\([\\\\\"'])/, '$1');\n }\n return replacement({ name, operator, quote, value });\n });\n }\n function removeAttrSelectorValues(selector) {\n let values = [];\n selector = replaceAttrSelectors(selector, function ({ name, value }) {\n values.push(value);\n return `[${name}]`;\n });\n return [selector, values];\n }\n function affix(parent, ...args) {\n let position, selector;\n const attributes = u.extractOptions(args);\n if (args.length === 2) {\n [position, selector] = args;\n }\n else {\n position = 'beforeend';\n selector = args[0];\n }\n const element = createFromSelector(selector, attributes);\n parent.insertAdjacentElement(position, element);\n return element;\n }\n const SINGLETON_TAG_NAMES = ['HTML', 'BODY', 'HEAD', 'TITLE'];\n const isSingleton = up.mockable(element => element.matches(SINGLETON_TAG_NAMES.join()));\n function elementTagName(element) {\n return element.tagName.toLowerCase();\n }\n function attrSelector(attribute, value) {\n if (u.isGiven(value)) {\n value = value.replace(/\"/g, '\\\\\"');\n return `[${attribute}=\"${value}\"]`;\n }\n else {\n return `[${attribute}]`;\n }\n }\n function idSelector(id) {\n if (id.match(/^[a-z0-9\\-_]+$/i)) {\n return `#${id}`;\n }\n else {\n return attrSelector('id', id);\n }\n }\n function classSelector(klass) {\n klass = klass.replace(/[^\\w-]/g, '\\\\$&');\n return `.${klass}`;\n }\n function createBrokenDocumentFromHTML(html) {\n return new DOMParser().parseFromString(html, 'text/html');\n }\n function fixParserDamage(scriptish) {\n let clone = createFromHTML(scriptish.outerHTML);\n scriptish.replaceWith(clone);\n }\n function createFromHTML(html) {\n const range = document.createRange();\n range.setStart(document.body, 0);\n const fragment = range.createContextualFragment(html.trim());\n let elements = fragment.childNodes;\n if (elements.length !== 1) {\n throw new Error('HTML must have a single root element');\n }\n return elements[0];\n }\n function getRoot() {\n return document.documentElement;\n }\n function paint(element) {\n element.offsetHeight;\n }\n function concludeCSSTransition(element) {\n const undo = setTemporaryStyle(element, { transition: 'none' });\n paint(element);\n return undo;\n }\n function hasCSSTransition(elementOrStyleHash) {\n let styleHash;\n if (u.isOptions(elementOrStyleHash)) {\n styleHash = elementOrStyleHash;\n }\n else {\n styleHash = computedStyle(elementOrStyleHash);\n }\n const prop = styleHash.transitionProperty;\n const duration = styleHash.transitionDuration;\n const noTransition = ((prop === 'none') || ((prop === 'all') && (duration === 0)));\n return !noTransition;\n }\n function fixedToAbsolute(element) {\n const elementRectAsFixed = element.getBoundingClientRect();\n element.style.position = 'absolute';\n const offsetParentRect = element.offsetParent.getBoundingClientRect();\n setInlineStyle(element, {\n left: elementRectAsFixed.left - computedStyleNumber(element, 'margin-left') - offsetParentRect.left,\n top: elementRectAsFixed.top - computedStyleNumber(element, 'margin-top') - offsetParentRect.top,\n right: '',\n bottom: ''\n });\n }\n function setMissingAttrs(element, attrs) {\n for (let key in attrs) {\n setMissingAttr(element, key, attrs[key]);\n }\n }\n function setMissingAttr(element, key, value) {\n if (u.isMissing(element.getAttribute(key))) {\n element.setAttribute(key, value);\n }\n }\n function unwrap(wrapper) {\n preservingFocus(function () {\n const parent = wrapper.parentNode;\n const wrappedNodes = u.toArray(wrapper.childNodes);\n u.each(wrappedNodes, wrappedNode => parent.insertBefore(wrappedNode, wrapper));\n parent.removeChild(wrapper);\n });\n }\n function wrapChildren(element) {\n let childNode;\n const wrapper = document.createElement('up-wrapper');\n while ((childNode = element.firstChild)) {\n wrapper.appendChild(childNode);\n }\n element.appendChild(wrapper);\n return wrapper;\n }\n function isWrapper(element) {\n return element.matches('up-wrapper');\n }\n function preservingFocus(fn) {\n const oldFocusElement = document.activeElement;\n try {\n return fn();\n }\n finally {\n if (oldFocusElement && oldFocusElement !== document.activeElement) {\n oldFocusElement.focus({ preventScroll: true });\n }\n }\n }\n function stringAttr(element, attribute) {\n return u.nullToUndefined(element.getAttribute(attribute));\n }\n function booleanAttr(element, attribute, pass) {\n if (!element.hasAttribute(attribute))\n return;\n const value = stringAttr(element, attribute);\n switch (value) {\n case 'false': {\n return false;\n }\n case 'true':\n case '':\n case attribute: {\n return true;\n }\n default: {\n if (pass) {\n return value;\n }\n else {\n return true;\n }\n }\n }\n }\n function booleanOrStringAttr(element, attribute) {\n return booleanAttr(element, attribute, true);\n }\n function numberAttr(element, attribute) {\n let value = element.getAttribute(attribute);\n if (value) {\n value = value.replace(/_/g, '');\n if (value.match(/^[\\d.]+$/)) {\n return parseFloat(value);\n }\n }\n }\n function jsonAttr(element, attribute) {\n let json = element.getAttribute?.(attribute)?.trim();\n if (json) {\n return JSON.parse(json);\n }\n }\n function callbackAttr(link, attr, { exposedKeys = [], mainKey = 'event' } = {}) {\n let code = link.getAttribute(attr);\n if (code) {\n const callback = up.NonceableCallback.fromString(code).toFunction(mainKey, ...exposedKeys);\n return function (event) {\n const exposedValues = Object.values(u.pick(event, exposedKeys));\n return callback.call(link, event, ...exposedValues);\n };\n }\n }\n function closestAttr(element, attr, parseFn = stringAttr) {\n let match = element.closest('[' + attr + ']');\n if (match) {\n return parseFn(match, attr);\n }\n }\n function setTemporaryStyle(element, newStyles) {\n const oldStyles = inlineStyle(element, Object.keys(newStyles));\n setInlineStyle(element, newStyles);\n return () => setInlineStyle(element, oldStyles);\n }\n function addTemporaryClass(element, klass) {\n element.classList.add(klass);\n return () => element.classList.remove(klass);\n }\n function setTemporaryAttr(element, attr, value) {\n element.setAttribute(attr, value);\n return () => element.removeAttribute(element, attr);\n }\n function computedStyle(element, props) {\n const style = window.getComputedStyle(element);\n return extractFromStyleObject(style, props);\n }\n function computedStyleNumber(element, prop) {\n const rawValue = computedStyle(element, prop);\n if (u.isGiven(rawValue)) {\n return parseFloat(rawValue);\n }\n }\n function inlineStyle(element, props) {\n const { style } = element;\n return extractFromStyleObject(style, props);\n }\n function extractFromStyleObject(style, keyOrKeys) {\n if (u.isString(keyOrKeys)) {\n return style[keyOrKeys];\n }\n else {\n return u.pick(style, keyOrKeys);\n }\n }\n function setInlineStyle(element, props) {\n if (u.isString(props)) {\n element.setAttribute('style', props);\n }\n else {\n const { style } = element;\n for (let key in props) {\n let value = props[key];\n value = normalizeStyleValueForWrite(key, value);\n style[key] = value;\n }\n }\n }\n function normalizeStyleValueForWrite(key, value) {\n if (u.isMissing(value)) {\n value = '';\n }\n else if (CSS_LENGTH_PROPS.has(key.toLowerCase().replace(/-/, ''))) {\n value = cssLength(value);\n }\n return value;\n }\n const CSS_LENGTH_PROPS = new Set([\n 'top', 'right', 'bottom', 'left',\n 'padding', 'paddingtop', 'paddingright', 'paddingbottom', 'paddingleft',\n 'margin', 'margintop', 'marginright', 'marginbottom', 'marginleft',\n 'borderwidth', 'bordertopwidth', 'borderrightwidth', 'borderbottomwidth', 'borderleftwidth',\n 'width', 'height',\n 'maxwidth', 'maxheight',\n 'minwidth', 'minheight',\n ]);\n function cssLength(obj) {\n if (u.isNumber(obj) || (u.isString(obj) && /^\\d+$/.test(obj))) {\n return obj.toString() + \"px\";\n }\n else {\n return obj;\n }\n }\n function isVisible(element) {\n return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);\n }\n function isUpPrefixed(string) {\n return /^up-/.test(string);\n }\n function upAttrs(element) {\n let attrNames = u.filter(element.getAttributeNames(), isUpPrefixed);\n return u.mapObject(attrNames, (name) => [name, element.getAttribute(name)]);\n }\n function upClasses(element) {\n return u.filter(element.classList.values(), isUpPrefixed);\n }\n function cleanJQuery(element) {\n if (up.browser.canJQuery()) {\n jQuery(element).remove();\n }\n }\n function isEmpty(element) {\n return !element.children.length > 0 && !element.innerText.trim();\n }\n function crossOriginSelector(attr) {\n return `[${attr}*=\"//\"]:not([${attr}*=\"//${location.host}/\"])`;\n }\n return {\n subtree,\n contains,\n closestAttr,\n ancestor,\n around,\n get: getOne,\n list: getList,\n toggle,\n hide,\n show,\n metaContent,\n insertBefore,\n createFromSelector,\n setAttrs,\n setTemporaryAttrs,\n affix,\n idSelector,\n classSelector,\n isSingleton,\n attrSelector,\n tagName: elementTagName,\n createBrokenDocumentFromHTML,\n fixParserDamage,\n createFromHTML,\n get root() { return getRoot(); },\n paint,\n concludeCSSTransition,\n hasCSSTransition,\n fixedToAbsolute,\n setMissingAttrs,\n setMissingAttr,\n unwrap,\n wrapChildren,\n isWrapper,\n attr: stringAttr,\n booleanAttr,\n numberAttr,\n jsonAttr,\n callbackAttr,\n booleanOrStringAttr,\n setTemporaryStyle,\n style: computedStyle,\n styleNumber: computedStyleNumber,\n inlineStyle,\n setStyle: setInlineStyle,\n isVisible,\n upAttrs,\n upClasses,\n toggleAttr,\n addTemporaryClass,\n setTemporaryAttr,\n cleanJQuery,\n parseSelector,\n isEmpty,\n crossOriginSelector,\n };\n})();\n\n\n/***/ }),\n/* 8 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 9 */\n/***/ (() => {\n\nup.Error = class Error extends window.Error {\n constructor(message, props = {}) {\n if (Array.isArray(message)) {\n message = up.util.sprintf(...message);\n }\n super(message);\n let name = 'up.' + this.constructor.name;\n Object.assign(this, { name }, props);\n }\n};\n\n\n/***/ }),\n/* 10 */\n/***/ (() => {\n\nup.NotImplemented = class NotImplemented extends up.Error {\n};\n\n\n/***/ }),\n/* 11 */\n/***/ (() => {\n\nup.Aborted = class Aborted extends up.Error {\n constructor(message) {\n super(message, { name: 'AbortError' });\n }\n};\n\n\n/***/ }),\n/* 12 */\n/***/ (() => {\n\nup.CannotMatch = class CannotMatch extends up.Error {\n};\n\n\n/***/ }),\n/* 13 */\n/***/ (() => {\n\nup.CannotParse = class CannotParse extends up.Error {\n};\n\n\n/***/ }),\n/* 14 */\n/***/ (() => {\n\nup.CannotTarget = class CannotTarget extends up.Error {\n};\n\n\n/***/ }),\n/* 15 */\n/***/ (() => {\n\nup.Offline = class Offline extends up.Error {\n};\n\n\n/***/ }),\n/* 16 */\n/***/ (() => {\n\nconst u = up.util;\nup.Record = class Record {\n keys() {\n throw 'Return an array of keys';\n }\n defaults(_options) {\n return {};\n }\n constructor(options) {\n Object.assign(this, this.defaults(options), this.attributes(options));\n }\n attributes(source = this) {\n return u.pick(source, this.keys());\n }\n [u.copy.key]() {\n return u.variant(this);\n }\n [u.isEqual.key](other) {\n return (this.constructor === other.constructor) && u.isEqual(this.attributes(), other.attributes());\n }\n};\n\n\n/***/ }),\n/* 17 */\n/***/ (() => {\n\nconst u = up.util;\nup.Config = class Config {\n constructor(blueprintFn = (() => ({}))) {\n this._blueprintFn = blueprintFn;\n this.reset();\n document.addEventListener('up:framework:reset', () => this.reset());\n }\n reset() {\n Object.assign(this, this._blueprintFn());\n }\n matches(element, prop) {\n return element.matches(this.selector(prop));\n }\n selector(prop) {\n let includes = this[prop];\n let excludes = this['no' + u.upperCaseFirst(prop)];\n let selector = `:is(${includes.join()})`;\n if (u.isPresent(excludes))\n selector += `:not(${excludes.join()})`;\n return selector;\n }\n selectorFn(prop) {\n return () => this.selector(prop);\n }\n};\n\n\n/***/ }),\n/* 18 */\n/***/ (() => {\n\nlet enabledKey = 'up.log.enabled';\nlet enabled = false;\ntry {\n enabled = !!sessionStorage?.getItem(enabledKey);\n}\ncatch {\n}\nup.LogConfig = class LogConfig extends up.Config {\n constructor() {\n super(() => ({\n banner: true,\n format: true,\n }));\n }\n get enabled() {\n return enabled;\n }\n set enabled(newEnabled) {\n enabled = newEnabled;\n try {\n sessionStorage?.setItem(enabledKey, newEnabled ? '1' : '');\n }\n catch {\n }\n }\n};\n\n\n/***/ }),\n/* 19 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.OptionsParser = class OptionsParser {\n constructor(element, options, parserOptions = {}) {\n this._options = options;\n this._element = element;\n this._parserOptions = parserOptions;\n this._fail = parserOptions.fail;\n this._closest = parserOptions.closest;\n this._attrPrefix = parserOptions.attrPrefix || 'up-';\n this._defaults = parserOptions.defaults || {};\n }\n string(key, keyOptions) {\n this.parse(e.attr, key, keyOptions);\n }\n boolean(key, keyOptions) {\n this.parse(e.booleanAttr, key, keyOptions);\n }\n number(key, keyOptions) {\n this.parse(e.numberAttr, key, keyOptions);\n }\n booleanOrString(key, keyOptions) {\n this.parse(e.booleanOrStringAttr, key, keyOptions);\n }\n json(key, keyOptions) {\n this.parse(e.jsonAttr, key, keyOptions);\n }\n callback(key, keyOptions = {}) {\n let parser = (link, attr) => e.callbackAttr(link, attr, keyOptions);\n this.parse(parser, key, keyOptions);\n }\n parse(attrValueFn, key, keyOptions = {}) {\n const attrNames = u.wrapList(keyOptions.attr ?? this._attrNameForKey(key));\n let value = this._options[key];\n for (let attrName of attrNames) {\n value ??= this._parseFromAttr(attrValueFn, this._element, attrName);\n }\n value ??= keyOptions.default ?? this._defaults[key];\n let normalizeFn = keyOptions.normalize;\n if (normalizeFn) {\n value = normalizeFn(value);\n }\n if (u.isDefined(value)) {\n this._options[key] = value;\n }\n let failKey;\n if (this._fail && (failKey = up.fragment.failKey(key))) {\n const failAttrNames = u.compact(u.map(attrNames, (attrName) => this._deriveFailAttrName(attrName)));\n this.parse(attrValueFn, failKey, { ...keyOptions, attr: failAttrNames });\n }\n }\n include(optionsFn) {\n let fnResult = optionsFn(this._element, this._options, this._parserOptions);\n Object.assign(this._options, fnResult);\n }\n _parseFromAttr(attrValueFn, element, attrName) {\n if (this._closest) {\n return e.closestAttr(element, attrName, attrValueFn);\n }\n else {\n return attrValueFn(element, attrName);\n }\n }\n _deriveFailAttrName(attr) {\n return this._deriveFailAttrNameForPrefix(attr, this._attrPrefix + 'on-') ||\n this._deriveFailAttrNameForPrefix(attr, this._attrPrefix);\n }\n _deriveFailAttrNameForPrefix(attr, prefix) {\n if (attr.startsWith(prefix)) {\n return `${prefix}fail-${attr.substring(prefix.length)}`;\n }\n }\n _attrNameForKey(option) {\n return `${this._attrPrefix}${u.camelToKebabCase(option)}`;\n }\n};\n\n\n/***/ }),\n/* 20 */\n/***/ (() => {\n\nconst u = up.util;\nup.FIFOCache = class FIFOCache {\n constructor({ capacity = 10, normalizeKey = u.identity } = {}) {\n this._map = new Map();\n this._capacity = capacity;\n this._normalizeKey = normalizeKey;\n }\n get(key) {\n key = this._normalizeKey(key);\n return this._map.get(key);\n }\n set(key, value) {\n if (this._map.size === this._capacity) {\n let oldestKey = this._map.keys().next().value;\n this._map.delete(oldestKey);\n }\n key = this._normalizeKey(key);\n this._map.set(key, value);\n }\n clear() {\n this._map.clear();\n }\n};\n\n\n/***/ }),\n/* 21 */\n/***/ (() => {\n\nup.Rect = class Rect extends up.Record {\n keys() {\n return [\n 'left',\n 'top',\n 'width',\n 'height'\n ];\n }\n get bottom() {\n return this.top + this.height;\n }\n get right() {\n return this.left + this.width;\n }\n static fromElement(element) {\n return new (this)(element.getBoundingClientRect());\n }\n};\n\n\n/***/ }),\n/* 22 */\n/***/ (() => {\n\nconst e = up.element;\nup.BodyShifter = class BodyShifter {\n constructor() {\n this._unshiftFns = [];\n this._anchoredElements = new Set();\n this._stack = 0;\n }\n lowerStack() {\n this._stack--;\n if (this._stack === 0) {\n this._unshiftNow();\n }\n }\n raiseStack() {\n this._stack++;\n if (this._stack === 1) {\n this._shiftNow();\n }\n }\n onAnchoredElementInserted(element) {\n this._anchoredElements.add(element);\n if (this._isShifted()) {\n this._shiftAnchoredElement(element);\n }\n return () => this._anchoredElements.delete(element);\n }\n _isShifted() {\n return this._scrollbarTookSpace && this._stack > 0;\n }\n _shiftNow() {\n this._scrollbarWidth = up.viewport.scrollbarWidth();\n this._scrollbarTookSpace = up.viewport.rootHasReducedWidthFromScrollbar();\n if (!this._scrollbarTookSpace)\n return;\n this._shiftBody();\n for (let element of this._anchoredElements) {\n this._shiftAnchoredElement(element);\n }\n }\n _shiftBody() {\n const overflowElement = up.viewport.rootOverflowElement();\n this._changeStyle(overflowElement, { overflowY: 'hidden' });\n const { body } = document;\n const bodyRightPadding = e.styleNumber(body, 'paddingRight');\n const bodyRightShift = this._scrollbarWidth + bodyRightPadding;\n this._changeStyle(body, { paddingRight: bodyRightShift });\n }\n _shiftAnchoredElement(element) {\n const elementRight = e.styleNumber(element, 'right');\n const elementRightShift = this._scrollbarWidth + elementRight;\n this._changeStyle(element, { right: elementRightShift });\n }\n _changeStyle(element, styles) {\n this._unshiftFns.push(e.setTemporaryStyle(element, styles));\n }\n _unshiftNow() {\n let unshiftFn;\n while (unshiftFn = this._unshiftFns.pop()) {\n unshiftFn();\n }\n }\n};\n\n\n/***/ }),\n/* 23 */\n/***/ (() => {\n\nconst u = up.util;\nup.Change = class Change {\n constructor(options) {\n this.options = options;\n }\n execute() {\n throw new up.NotImplemented();\n }\n onFinished(renderResult) {\n return this.options.onFinished?.(renderResult);\n }\n improveHistoryValue(existingValue, newValue) {\n if ((existingValue === false) || u.isString(existingValue)) {\n return existingValue;\n }\n else {\n return newValue;\n }\n }\n deriveFailOptions() {\n return up.RenderOptions.deriveFailOptions(this.options);\n }\n};\n\n\n/***/ }),\n/* 24 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.Change.Addition = class Addition extends up.Change {\n constructor(options) {\n super(options);\n this._acceptLayer = options.acceptLayer;\n this._dismissLayer = options.dismissLayer;\n this._eventPlans = options.eventPlans || [];\n this._response = options.response;\n }\n handleLayerChangeRequests() {\n if (this.layer.isOverlay()) {\n this.tryAcceptLayerFromServer();\n this.abortWhenLayerClosed();\n this.layer.tryAcceptForLocation(this.responseOption());\n this.abortWhenLayerClosed();\n this.tryDismissLayerFromServer();\n this.abortWhenLayerClosed();\n this.layer.tryDismissForLocation(this.responseOption());\n this.abortWhenLayerClosed();\n }\n this.layer.asCurrent(() => {\n for (let eventPlan of this._eventPlans) {\n up.emit({ ...eventPlan, ...this.responseOption() });\n this.abortWhenLayerClosed();\n }\n });\n }\n tryAcceptLayerFromServer() {\n if (u.isDefined(this._acceptLayer) && this.layer.isOverlay()) {\n this.layer.accept(this._acceptLayer, this.responseOption());\n }\n }\n tryDismissLayerFromServer() {\n if (u.isDefined(this._dismissLayer) && this.layer.isOverlay()) {\n this.layer.dismiss(this._dismissLayer, this.responseOption());\n }\n }\n abortWhenLayerClosed(layer = this.layer) {\n if (layer.isClosed()) {\n throw new up.Aborted('Layer was closed');\n }\n }\n setSource({ oldElement, newElement, source }) {\n if (source === 'keep') {\n source = (oldElement && up.fragment.source(oldElement));\n }\n if (source) {\n e.setMissingAttr(newElement, 'up-source', u.normalizeURL(source, { hash: false }));\n }\n }\n setTime({ newElement, time }) {\n e.setMissingAttr(newElement, 'up-time', time ? time.toUTCString() : false);\n }\n setETag({ newElement, etag }) {\n e.setMissingAttr(newElement, 'up-etag', etag || false);\n }\n setReloadAttrs(options) {\n this.setSource(options);\n this.setTime(options);\n this.setETag(options);\n }\n responseOption() {\n return { response: this._response };\n }\n executeSteps(steps, responseDoc, noneOptions) {\n return new up.Change.UpdateSteps({ steps, noneOptions }).execute(responseDoc);\n }\n};\n\n\n/***/ }),\n/* 25 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.RenderJob = (_a = class RenderJob {\n constructor(options) {\n this.options = up.RenderOptions.preprocess(options);\n }\n execute() {\n this._rendered = this._executePromise();\n return this;\n }\n async _executePromise() {\n try {\n this._guardRender();\n let result = await this._getChange().execute();\n this._handleResult(result);\n return result;\n }\n catch (resultOrError) {\n this._handleResult(resultOrError) || this._handleError(resultOrError);\n throw resultOrError;\n }\n }\n _handleResult(result) {\n if (result instanceof up.RenderResult) {\n let { onRendered, onFinished } = result.options;\n if (!result.none)\n up.error.guard(() => onRendered?.(result));\n let guardedOnFinished = function (result) {\n up.error.guard(() => onFinished?.(result));\n };\n this.finished.then(guardedOnFinished, u.noop);\n return true;\n }\n }\n _handleError(error) {\n let prefix = error instanceof up.Aborted ? 'Rendering was aborted' : 'Error while rendering';\n up.puts('up.render()', `${prefix}: ${error.name}: ${error.message}`);\n up.error.guard(() => this.options.onError?.(error));\n }\n get finished() {\n return this._awaitFinished();\n }\n async _awaitFinished() {\n try {\n let result = await this._rendered;\n return await result.finished;\n }\n catch (error) {\n if (error instanceof up.RenderResult) {\n throw await error.finished;\n }\n else {\n throw error;\n }\n }\n }\n _getChange() {\n if (this.options.url) {\n let onRequest = (request) => this._handleAbortOption(request);\n return new up.Change.FromURL({ ...this.options, onRequest });\n }\n else if (this.options.response) {\n let onRender = () => this._handleAbortOption(null);\n return new up.Change.FromResponse({ ...this.options, onRender });\n }\n else {\n let onRender = () => this._handleAbortOption(null);\n return new up.Change.FromContent({ ...this.options, onRender });\n }\n }\n _guardRender() {\n up.browser.assertConfirmed(this.options);\n let guardEvent = u.pluckKey(this.options, 'guardEvent');\n if (guardEvent) {\n guardEvent.renderOptions = this.options;\n if (up.emit(guardEvent, { target: this.options.origin }).defaultPrevented) {\n throw new up.Aborted(`Rendering was prevented by ${guardEvent.type} listener`);\n }\n }\n up.RenderOptions.assertContentGiven(this.options);\n }\n _handleAbortOption(request) {\n let { abort } = this.options;\n if (!abort || !up.network.isBusy())\n return;\n let { fragments, layer, origin, newLayer } = this._getChange().getPreflightProps();\n let abortOptions = {\n except: request,\n logOnce: ['up.render()', 'Change with { abort } option will abort other requests'],\n newLayer,\n origin,\n };\n if (abort === 'target') {\n up.fragment.abort(fragments, abortOptions);\n }\n else if (abort === 'layer') {\n up.fragment.abort({ ...abortOptions, layer });\n }\n else if (abort === 'all' || abort === true) {\n up.fragment.abort({ ...abortOptions, layer: 'any' });\n }\n else if (u.isFunction(abort)) {\n abort(abortOptions);\n }\n else {\n up.fragment.abort(abort, { ...abortOptions, layer });\n }\n }\n },\n (() => {\n u.delegate(_a.prototype, ['then', 'catch', 'finally'], function () { return this._rendered; });\n u.memoizeMethod(_a.prototype, {\n _awaitFinished: true,\n _getChange: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 26 */\n/***/ (() => {\n\nup.Change.Removal = class Removal extends up.Change {\n};\n\n\n/***/ }),\n/* 27 */\n/***/ (() => {\n\nup.Change.DestroyFragment = class DestroyFragment extends up.Change.Removal {\n constructor(options) {\n super(options);\n this._layer = up.layer.get(options) || up.layer.current;\n this._element = this.options.element;\n this._animation = this.options.animation;\n this._log = this.options.log;\n }\n execute() {\n this._parent = this._element.parentNode;\n up.fragment.markAsDestroying(this._element);\n if (up.motion.willAnimate(this._element, this._animation, this.options)) {\n this._destroyAfterAnimation();\n }\n else {\n this._destroyNow();\n }\n }\n async _destroyAfterAnimation() {\n this._emitDestroyed();\n await this._animate();\n this._wipe();\n this.onFinished();\n }\n _destroyNow() {\n this._wipe();\n this._emitDestroyed();\n this.onFinished();\n }\n _animate() {\n return up.motion.animate(this._element, this._animation, this.options);\n }\n _wipe() {\n this._layer.asCurrent(() => {\n up.fragment.abort(this._element);\n up.script.clean(this._element, { layer: this._layer });\n up.element.cleanJQuery(this._element);\n this._element.remove();\n });\n }\n _emitDestroyed() {\n up.fragment.emitDestroyed(this._element, { parent: this._parent, log: this._log });\n }\n};\n\n\n/***/ }),\n/* 28 */\n/***/ (() => {\n\nlet u = up.util;\nup.Change.OpenLayer = class OpenLayer extends up.Change.Addition {\n constructor(options) {\n super(options);\n this.target = options.target;\n this._origin = options.origin;\n this._baseLayer = options.baseLayer;\n }\n getPreflightProps() {\n return {\n mode: this.options.mode,\n context: this._buildLayer().context,\n origin: this.options.origin,\n target: this.target,\n layer: this._baseLayer,\n fragments: u.compact([up.fragment.get(':main', { layer: this._baseLayer })]),\n newLayer: true,\n };\n }\n execute(responseDoc, onApplicable) {\n this.responseDoc = responseDoc;\n this._matchPostflight();\n onApplicable();\n this._createOverlay();\n let unbindClosing = this.layer.on('up:layer:accepting up:layer:dimissing', this._renderOtherLayers.bind(this));\n try {\n this._renderOverlayContent();\n this._renderOtherLayers();\n return up.RenderResult.both(this._newOverlayResult, this._otherLayersResult);\n }\n finally {\n unbindClosing();\n }\n }\n _matchPostflight() {\n if (this.target === ':none') {\n this._content = document.createElement('up-none');\n }\n else {\n this._content = this.responseDoc.select(this.target);\n }\n if (!this._content || this._baseLayer.isClosed()) {\n throw new up.CannotMatch();\n }\n }\n _createOverlay() {\n up.puts('up.render()', `Opening element \"${this.target}\" in new overlay`);\n this._assertOpenEventEmitted();\n this.layer = this._buildLayer();\n this._baseLayer.peel({ history: !this.layer.history });\n up.layer.stack.push(this.layer);\n this.layer.createElements();\n this.layer.setupHandlers();\n }\n _renderOverlayContent() {\n this._handleHistory();\n this.handleLayerChangeRequests();\n this.responseDoc.commitElement(this._content);\n this.layer.setContent(this._content);\n this.setReloadAttrs({ newElement: this._content, source: this.options.source });\n this.responseDoc.finalizeElement(this._content);\n this._newOverlayResult = new up.RenderResult({\n layer: this.layer,\n fragments: [this._content],\n target: this.target,\n });\n up.hello(this.layer.element, { ...this.options, layer: this.layer });\n this._handleScroll();\n this._newOverlayResult.finished = this._finish();\n this.layer.opening = false;\n this._emitOpenedEvent();\n this.abortWhenLayerClosed();\n }\n _renderOtherLayers() {\n if (this._otherLayersResult)\n return;\n let otherLayerSteps = this._getHungrySteps().other;\n this._otherLayersResult = this.executeSteps(otherLayerSteps, this.responseDoc);\n }\n async _finish() {\n await this.layer.startOpenAnimation();\n this.abortWhenLayerClosed();\n this._handleFocus();\n return this._newOverlayResult;\n }\n _buildLayer() {\n const buildOptions = { ...this.options, opening: true };\n const beforeNew = optionsWithLayerDefaults => {\n return this.options = up.RenderOptions.finalize(optionsWithLayerDefaults);\n };\n return up.layer.build(buildOptions, beforeNew);\n }\n _handleHistory() {\n if (this.layer.history === 'auto') {\n this.layer.history = up.fragment.hasAutoHistory([this._content], this.layer);\n }\n let { parent } = this.layer;\n this.layer.history &&= parent.history;\n parent.saveHistory();\n this.layer.updateHistory(this.options);\n }\n _handleFocus() {\n this._baseLayer.overlayFocus?.moveToBack();\n this.layer.overlayFocus.moveToFront();\n const fragmentFocus = new up.FragmentFocus({\n fragment: this._content,\n layer: this.layer,\n autoMeans: ['autofocus', 'layer'],\n inputDevice: this.options.inputDevice,\n });\n fragmentFocus.process(this.options.focus);\n }\n _handleScroll() {\n const scrollingOptions = {\n ...this.options,\n fragment: this._content,\n layer: this.layer,\n autoMeans: ['hash', 'layer']\n };\n const scrolling = new up.FragmentScrolling(scrollingOptions);\n scrolling.process(this.options.scroll);\n }\n _assertOpenEventEmitted() {\n up.event.assertEmitted('up:layer:open', {\n origin: this._origin,\n baseLayer: this._baseLayer,\n layerOptions: this.options,\n log: \"Opening new overlay\"\n });\n }\n _emitOpenedEvent() {\n this.layer.emit('up:layer:opened', {\n origin: this._origin,\n callback: this.layer.callback('onOpened'),\n log: `Opened new ${this.layer}`\n });\n }\n _getHungrySteps() {\n return up.radio.hungrySteps(this._getEffectiveRenderOptions());\n }\n _getEffectiveRenderOptions() {\n return {\n ...this.options,\n layer: this.layer,\n history: this.layer.history,\n };\n }\n};\n\n\n/***/ }),\n/* 29 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {\n constructor(options) {\n options = up.RenderOptions.finalize(options);\n super(options);\n this.layer = options.layer;\n this.target = options.target;\n this._context = options.context;\n this._steps = up.fragment.parseTargetSteps(this.target, this.options);\n }\n getPreflightProps() {\n this._matchPreflight();\n return {\n layer: this.layer,\n mode: this.layer.mode,\n context: u.merge(this.layer.context, this._context),\n origin: this.options.origin,\n target: this._bestPreflightSelector(),\n fragments: this._getFragments(),\n newLayer: false,\n };\n }\n _bestPreflightSelector() {\n this._matchPreflight();\n return up.fragment.targetForSteps(this._steps);\n }\n _getFragments() {\n this._matchPreflight();\n return u.map(this._steps, 'oldElement');\n }\n execute(responseDoc, onApplicable) {\n this.responseDoc = responseDoc;\n this._matchPostflight();\n onApplicable();\n let unbindClosing = this.layer.on('up:layer:accepting up:layer:dimissing', this._renderOtherLayers.bind(this));\n try {\n this._renderCurrentLayer();\n this._renderOtherLayers();\n return up.RenderResult.both(this._currentLayerResult, this._otherLayersResult);\n }\n finally {\n unbindClosing();\n }\n }\n _renderCurrentLayer() {\n if (this._steps.length) {\n up.puts('up.render()', `Updating \"${this._bestPreflightSelector()}\" in ${this.layer}`);\n }\n this._setScrollAndFocusOptions();\n if (this.options.saveScroll) {\n up.viewport.saveScroll({ layer: this.layer });\n }\n if (this.options.saveFocus) {\n up.viewport.saveFocus({ layer: this.layer });\n }\n if (this.options.peel) {\n this.layer.peel({ history: !this._hasHistory() });\n }\n if (this.options.abort !== false) {\n up.fragment.abort(this._getFragments(), { reason: 'Fragment is being replaced' });\n }\n Object.assign(this.layer.context, this._context);\n if (this._hasHistory()) {\n this.layer.updateHistory(this.options);\n }\n this.handleLayerChangeRequests();\n this._currentLayerResult = this.executeSteps(this._steps, this.responseDoc, this.options);\n }\n _renderOtherLayers() {\n if (this._otherLayersResult)\n return;\n let otherLayerSteps = this._getHungrySteps().other;\n this._otherLayersResult = this.executeSteps(otherLayerSteps, this.responseDoc);\n }\n _matchPreflight() {\n this._matchOldElements();\n this._compressNestedSteps();\n }\n _matchPostflight() {\n this._matchOldElements();\n this._addHungryStepsOnCurrentLayer();\n this._compressNestedSteps();\n this._matchNewElements();\n }\n _addHungryStepsOnCurrentLayer() {\n this._steps.push(...this._getHungrySteps().current);\n }\n _matchOldElements() {\n this._steps = this._steps.filter((step) => {\n const finder = new up.FragmentFinder(u.pick(step, ['selector', 'origin', 'layer', 'match', 'preferOldElements']));\n step.oldElement ||= finder.find();\n if (step.oldElement) {\n return true;\n }\n else if (!step.maybe) {\n throw new up.CannotMatch();\n }\n });\n }\n _matchNewElements() {\n this._steps = this.responseDoc.selectSteps(this._steps);\n }\n _compressNestedSteps() {\n this._steps = up.fragment.compressNestedSteps(this._steps);\n }\n _getHungrySteps() {\n return up.radio.hungrySteps(this._getEffectiveRenderOptions());\n }\n _setScrollAndFocusOptions() {\n let focusCapsule = up.FocusCapsule.preserve(this.layer);\n this._steps.forEach((step, i) => {\n step.focusCapsule = focusCapsule;\n if (i > 0) {\n step.scroll = false;\n step.focus = false;\n }\n if ((step.placement === 'swap') || (step.placement === 'content')) {\n step.scrollBehavior = 'instant';\n }\n });\n }\n _hasHistory() {\n return u.evalAutoOption(this.options.history, this._hasAutoHistory.bind(this));\n }\n _hasAutoHistory() {\n const oldFragments = u.map(this._steps, 'oldElement');\n return up.fragment.hasAutoHistory(oldFragments, this.layer);\n }\n _getEffectiveRenderOptions() {\n return {\n ...this.options,\n layer: this.layer,\n history: this._hasHistory(),\n };\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _matchPreflight: true,\n _matchOldElements: true,\n _hasHistory: true,\n _getHungrySteps: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 30 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {\n constructor(options) {\n super(options);\n this._noneOptions = options.noneOptions || {};\n this._steps = u.copy(options.steps);\n }\n execute(responseDoc) {\n this.responseDoc = responseDoc;\n this._steps = responseDoc.selectSteps(this._steps);\n this._steps = responseDoc.commitSteps(this._steps);\n if (!this._steps.length) {\n return this._executeNone();\n }\n this.renderResult = new up.RenderResult({\n layer: this._steps[0]?.layer,\n target: up.fragment.targetForSteps(this._steps),\n });\n this._steps.reverse();\n const motionEndPromises = this._steps.map(step => this._executeStep(step));\n this.renderResult.finished = this._finish(motionEndPromises);\n return this.renderResult;\n }\n _executeNone() {\n this._handleFocus(null, this._noneOptions);\n this._handleScroll(null, this._noneOptions);\n return up.RenderResult.buildNone();\n }\n async _finish(motionEndPromises) {\n await Promise.all(motionEndPromises);\n for (let step of this._steps) {\n this.abortWhenLayerClosed(step.layer);\n }\n return this.renderResult;\n }\n _addToResult(fragment) {\n let newFragments = fragment.matches('up-wrapper') ? fragment.children : [fragment];\n this.renderResult.fragments.unshift(...newFragments);\n }\n _executeStep(step) {\n this.setReloadAttrs(step);\n switch (step.placement) {\n case 'swap': {\n let keepPlan = this._findKeepPlan(step);\n if (keepPlan) {\n this._handleFocus(step.oldElement, step);\n this._handleScroll(step.oldElement, step);\n return Promise.resolve();\n }\n else {\n this._preserveKeepables(step);\n const parent = step.oldElement.parentNode;\n const morphOptions = {\n ...step,\n beforeStart() {\n up.fragment.markAsDestroying(step.oldElement);\n },\n afterInsert: () => {\n this._restoreKeepables(step);\n this.responseDoc.finalizeElement(step.newElement);\n this._unmarkKeepables(step);\n up.hello(step.newElement, step);\n this._addToResult(step.newElement);\n },\n beforeDetach: () => {\n up.script.clean(step.oldElement, { layer: step.layer });\n },\n afterDetach() {\n up.element.cleanJQuery();\n up.fragment.emitDestroyed(step.oldElement, { parent, log: false });\n },\n scrollNew: () => {\n this._handleFocus(step.newElement, step);\n this._handleScroll(step.newElement, step);\n }\n };\n return up.morph(step.oldElement, step.newElement, step.transition, morphOptions);\n }\n }\n case 'content': {\n let oldWrapper = e.wrapChildren(step.oldElement);\n let newWrapper = e.wrapChildren(step.newElement);\n let wrapperStep = {\n ...step,\n placement: 'swap',\n oldElement: oldWrapper,\n newElement: newWrapper,\n focus: false\n };\n return this._executeStep(wrapperStep).then(() => {\n e.unwrap(newWrapper);\n this._handleFocus(step.oldElement, step);\n });\n }\n case 'before':\n case 'after': {\n let wrapper = e.wrapChildren(step.newElement);\n let position = step.placement === 'before' ? 'afterbegin' : 'beforeend';\n step.oldElement.insertAdjacentElement(position, wrapper);\n this.responseDoc.finalizeElement(wrapper);\n up.hello(wrapper, step);\n this._addToResult(wrapper);\n this._handleFocus(wrapper, step);\n this._handleScroll(wrapper, step);\n return up.animate(wrapper, step.transition, step).then(() => e.unwrap(wrapper));\n }\n default: {\n up.fail('Unknown placement: %o', step.placement);\n }\n }\n }\n _findKeepPlan(options) {\n if (!options.useKeep) {\n return;\n }\n const { oldElement, newElement } = options;\n let doKeep = e.booleanAttr(oldElement, 'up-keep');\n if (!doKeep) {\n return;\n }\n let partner;\n let partnerSelector = up.fragment.toTarget(oldElement);\n const lookupOpts = { layer: options.layer };\n if (options.descendantsOnly) {\n partner = up.fragment.get(newElement, partnerSelector, lookupOpts);\n }\n else {\n partner = up.fragment.subtree(newElement, partnerSelector, lookupOpts)[0];\n }\n if (partner && e.booleanAttr(partner, 'up-keep') !== false) {\n const plan = {\n oldElement,\n newElement: partner,\n newData: up.script.data(partner),\n renderOptions: options,\n };\n if (!up.fragment.emitKeep(plan).defaultPrevented) {\n return plan;\n }\n }\n }\n _preserveKeepables(step) {\n const keepPlans = [];\n if (step.useKeep) {\n for (let keepable of step.oldElement.querySelectorAll('[up-keep]')) {\n let keepPlan = this._findKeepPlan({ ...step, oldElement: keepable, descendantsOnly: true });\n if (keepPlan) {\n const keepableClone = keepable.cloneNode(true);\n keepable.insertAdjacentElement('beforebegin', keepableClone);\n keepable.classList.add('up-keeping');\n up.script.disableSubtree(keepPlan.newElement);\n let viewports = up.viewport.subtree(keepPlan.oldElement);\n keepPlan.revivers = viewports.map(function (viewport) {\n let cursorProps = up.viewport.copyCursorProps(viewport);\n return () => up.viewport.copyCursorProps(cursorProps, viewport);\n });\n if (this._willChangeElement(document.body)) {\n keepPlan.newElement.replaceWith(keepable);\n }\n else {\n document.body.append(keepable);\n }\n keepPlans.push(keepPlan);\n }\n }\n }\n step.keepPlans = keepPlans;\n }\n _restoreKeepables(step) {\n for (let keepPlan of step.keepPlans) {\n keepPlan.newElement.replaceWith(keepPlan.oldElement);\n for (let reviver of keepPlan.revivers) {\n reviver();\n }\n }\n }\n _unmarkKeepables(step) {\n for (let keepPlan of step.keepPlans) {\n keepPlan.oldElement.classList.remove('up-keeping');\n }\n }\n _willChangeElement(element) {\n return u.some(this._steps, (step) => step.oldElement.contains(element));\n }\n _handleFocus(fragment, options) {\n const fragmentFocus = new up.FragmentFocus({\n ...options,\n fragment,\n autoMeans: up.fragment.config.autoFocus,\n });\n return fragmentFocus.process(options.focus);\n }\n _handleScroll(fragment, options) {\n const scrolling = new up.FragmentScrolling({\n ...options,\n fragment,\n autoMeans: up.fragment.config.autoScroll\n });\n return scrolling.process(options.scroll);\n }\n};\n\n\n/***/ }),\n/* 31 */\n/***/ (() => {\n\nconst u = up.util;\nup.Change.CloseLayer = class CloseLayer extends up.Change.Removal {\n constructor(options) {\n super(options);\n this._verb = options.verb;\n this._layer = up.layer.get(options);\n this._origin = options.origin;\n this._value = options.value;\n this._preventable = options.preventable ?? true;\n this._response = options.response;\n this._history = options.history ?? true;\n }\n execute() {\n if (!this._layer.isOpen()) {\n return Promise.resolve();\n }\n up.browser.assertConfirmed(this.options);\n if (this._emitCloseEvent().defaultPrevented && this._preventable) {\n throw new up.Aborted('Close event was prevented');\n }\n this._emitClosingEvent();\n up.fragment.abort({ reason: 'Layer is closing', layer: this._layer });\n const { parent } = this._layer;\n this._layer.peel();\n this._layer.stack.remove(this._layer);\n if (this._history) {\n parent.restoreHistory();\n }\n this._handleFocus(parent);\n this._layer.teardownHandlers();\n this._layer.destroyElements(this.options);\n this._emitClosedEvent(parent);\n }\n _emitCloseEvent() {\n let event = this._layer.emit(this._buildEvent(`up:layer:${this._verb}`), {\n callback: this._layer.callback(`on${u.upperCaseFirst(this._verb)}`),\n log: [`Will ${this._verb} ${this._layer} with value %o`, this._value]\n });\n this._value = event.value;\n return event;\n }\n _emitClosingEvent() {\n let event = this._buildEvent(`up:layer:${this._verb}ing`);\n this._layer.emit(event, { log: false });\n }\n _emitClosedEvent(formerParent) {\n const verbPast = `${this._verb}ed`;\n const verbPastUpperCaseFirst = u.upperCaseFirst(verbPast);\n return this._layer.emit(this._buildEvent(`up:layer:${verbPast}`), {\n baseLayer: formerParent,\n callback: this._layer.callback(`on${verbPastUpperCaseFirst}`),\n ensureBubbles: true,\n log: [`${verbPastUpperCaseFirst} ${this._layer} with value %o`, this._value]\n });\n }\n _buildEvent(name) {\n return up.event.build(name, {\n layer: this._layer,\n value: this._value,\n origin: this._origin,\n response: this._response,\n });\n }\n _handleFocus(formerParent) {\n this._layer.overlayFocus.teardown();\n formerParent.overlayFocus?.moveToFront();\n let newFocusElement = this._layer.origin || formerParent.element;\n up.focus(newFocusElement, { preventScroll: true });\n }\n};\n\n\n/***/ }),\n/* 32 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.Change.FromURL = (_a = class FromURL extends up.Change {\n constructor(options) {\n super(options);\n this.options.layer = up.layer.getAll(this.options);\n this.options.normalizeLayerOptions = false;\n }\n execute() {\n let _newPageReason = this._newPageReason();\n if (_newPageReason) {\n up.puts('up.render()', _newPageReason);\n up.network.loadPage(this.options);\n return u.unresolvablePromise();\n }\n this.request = up.request(this._getRequestAttrs());\n this.options.onRequest?.(this.request);\n up.feedback.showAroundRequest(this.request, this.options);\n up.form.disableWhile(this.request, this.options);\n if (this.options.preload) {\n return this.request;\n }\n return u.always(this.request, responseOrError => this._onRequestSettled(responseOrError));\n }\n _newPageReason() {\n if (u.isCrossOrigin(this.options.url)) {\n return 'Loading cross-origin content in new page';\n }\n if (this.options.history && !up.browser.canPushState()) {\n return 'Loading content in new page to restore history support';\n }\n }\n _getRequestAttrs() {\n const successAttrs = this._preflightPropsForRenderOptions(this.options);\n const failAttrs = this._preflightPropsForRenderOptions(this.deriveFailOptions(), { optional: true });\n return {\n ...this.options,\n ...successAttrs,\n ...u.renameKeys(failAttrs, up.fragment.failKey)\n };\n }\n getPreflightProps() {\n return this._getRequestAttrs();\n }\n _preflightPropsForRenderOptions(renderOptions, requestAttributesOptions) {\n const preview = new up.Change.FromContent({ ...renderOptions, preview: true });\n return preview.getPreflightProps(requestAttributesOptions);\n }\n _onRequestSettled(response) {\n if (response instanceof up.Response) {\n return this._onRequestSettledWithResponse(response);\n }\n else {\n return this._onRequestSettledWithError(response);\n }\n }\n _onRequestSettledWithResponse(response) {\n return new up.Change.FromResponse({ ...this.options, response }).execute();\n }\n _onRequestSettledWithError(error) {\n if (error instanceof up.Offline) {\n this.request.emit('up:fragment:offline', {\n callback: this.options.onOffline,\n renderOptions: this.options,\n retry: (retryOptions) => up.render({ ...this.options, ...retryOptions }),\n log: ['Cannot load fragment from %s: %s', this.request.description, error.reason],\n });\n }\n throw error;\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _getRequestAttrs: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 33 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.Change.FromResponse = (_a = class FromResponse extends up.Change {\n constructor(options) {\n super(options);\n this._response = options.response;\n this._request = this._response.request;\n }\n execute() {\n if (up.fragment.config.skipResponse(this._loadedEventProps())) {\n this._skip();\n }\n else {\n this._request.assertEmitted('up:fragment:loaded', {\n ...this._loadedEventProps(),\n callback: this.options.onLoaded,\n log: ['Loaded fragment from %s', this._response.description],\n skip: () => this._skip()\n });\n }\n let fail = u.evalOption(this.options.fail, this._response) ?? !this._response.ok;\n if (fail) {\n throw this._updateContentFromResponse(this.deriveFailOptions());\n }\n return this._updateContentFromResponse(this.options);\n }\n _skip() {\n up.puts('up.render()', 'Skipping ' + this._response.description);\n this.options.target = ':none';\n this.options.failTarget = ':none';\n }\n _updateContentFromResponse(finalRenderOptions) {\n if (finalRenderOptions.failPrefixForced) {\n up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');\n }\n this._augmentOptionsFromResponse(finalRenderOptions);\n finalRenderOptions.meta = this._compilerPassMeta();\n let result = new up.Change.FromContent(finalRenderOptions).execute();\n result.finished = this.finish(result, finalRenderOptions);\n return result;\n }\n async finish(renderResult, originalRenderOptions) {\n renderResult = await renderResult.finished;\n if (up.fragment.shouldRevalidate(this._request, this._response, originalRenderOptions)) {\n renderResult = await this._revalidate(renderResult, originalRenderOptions);\n }\n return renderResult;\n }\n async _revalidate(renderResult, originalRenderOptions) {\n let inputTarget = originalRenderOptions.target;\n let effectiveTarget = renderResult.target;\n if (/:(before|after)/.test(inputTarget)) {\n up.warn('up.render()', 'Cannot revalidate cache when prepending/appending (target %s)', inputTarget);\n }\n else {\n up.puts('up.render()', 'Revalidating cached response for target \"%s\"', effectiveTarget);\n let verifyResult = await up.reload(effectiveTarget, {\n ...originalRenderOptions,\n preferOldElements: renderResult.fragments,\n layer: renderResult.layer,\n onFinished: null,\n scroll: false,\n focus: 'keep',\n transition: false,\n cache: false,\n confirm: false,\n feedback: false,\n abort: false,\n expiredResponse: this._response,\n });\n if (!verifyResult.none) {\n renderResult = verifyResult;\n }\n }\n return renderResult;\n }\n _loadedEventProps() {\n const { expiredResponse } = this.options;\n return {\n request: this._request,\n response: this._response,\n renderOptions: this.options,\n revalidating: !!expiredResponse,\n expiredResponse,\n };\n }\n _compilerPassMeta() {\n let meta = { revalidating: !!this.options.expiredResponse };\n up.migrate.processCompilerPassMeta?.(meta, this._response);\n return meta;\n }\n _augmentOptionsFromResponse(renderOptions) {\n const responseURL = this._response.url;\n let serverLocation = responseURL;\n let hash = this._request.hash;\n if (hash) {\n renderOptions.hash = hash;\n serverLocation += hash;\n }\n const isReloadable = (this._response.method === 'GET');\n if (isReloadable) {\n renderOptions.source = this.improveHistoryValue(renderOptions.source, responseURL);\n }\n else {\n renderOptions.source = this.improveHistoryValue(renderOptions.source, 'keep');\n renderOptions.history = !!renderOptions.location;\n }\n renderOptions.location = this.improveHistoryValue(renderOptions.location, serverLocation);\n renderOptions.title = this.improveHistoryValue(renderOptions.title, this._response.title);\n renderOptions.eventPlans = this._response.eventPlans;\n let serverTarget = this._response.target;\n if (serverTarget) {\n renderOptions.target = serverTarget;\n }\n renderOptions.acceptLayer = this._response.acceptLayer;\n renderOptions.dismissLayer = this._response.dismissLayer;\n renderOptions.document = this._response.text;\n if (this._response.none) {\n renderOptions.target = ':none';\n }\n renderOptions.context = u.merge(renderOptions.context, this._response.context);\n renderOptions.cspNonces = this._response.cspNonces;\n renderOptions.time ??= this._response.lastModified;\n renderOptions.etag ??= this._response.etag;\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _loadedEventProps: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 34 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.Change.FromContent = (_a = class FromContent extends up.Change {\n constructor(options) {\n super(options);\n this._origin = this.options.origin;\n this._preview = this.options.preview;\n }\n _getPlans() {\n let plans = [];\n this._lookupLayers();\n this._improveOptionsFromResponseDoc();\n this._expandIntoPlans(plans, this._layers, this.options.target);\n this._expandIntoPlans(plans, this._layers, this.options.fallback);\n return plans;\n }\n _isRenderableLayer(layer) {\n return (layer === 'new') || layer.isOpen();\n }\n _lookupLayers() {\n this._allLayers = up.layer.getAll(this.options);\n this._layers = u.filter(this._allLayers, this._isRenderableLayer);\n }\n _expandIntoPlans(plans, layers, targets) {\n for (let layer of layers) {\n for (let target of this._expandTargets(targets, layer)) {\n const props = { ...this.options, target, layer, defaultPlacement: this._defaultPlacement() };\n const change = layer === 'new' ? new up.Change.OpenLayer(props) : new up.Change.UpdateLayer(props);\n plans.push(change);\n }\n }\n }\n _expandTargets(targets, layer) {\n return up.fragment.expandTargets(targets, { layer, mode: this.options.mode, origin: this._origin });\n }\n execute() {\n if (this.options.preload) {\n return Promise.resolve();\n }\n return this._seekPlan(this._executePlan.bind(this)) || this._cannotMatchPostflightTarget();\n }\n _executePlan(matchedPlan) {\n let result = matchedPlan.execute(this._getResponseDoc(), this._onPlanApplicable.bind(this, matchedPlan));\n result.options = this.options;\n return result;\n }\n _isApplicablePlanError(error) {\n return !(error instanceof up.CannotMatch);\n }\n _onPlanApplicable(plan) {\n let primaryPlan = this._getPlans()[0];\n if (plan !== primaryPlan) {\n up.puts('up.render()', 'Could not match primary target \"%s\". Updating a fallback target \"%s\".', primaryPlan.target, plan.target);\n }\n let { assets } = this._getResponseDoc();\n if (assets) {\n up.script.assertAssetsOK(assets, plan.options);\n }\n this.options.onRender?.();\n }\n _getResponseDoc() {\n if (this._preview)\n return;\n const docOptions = u.pick(this.options, [\n 'target',\n 'content',\n 'fragment',\n 'document',\n 'html',\n 'cspNonces',\n 'origin',\n ]);\n up.migrate.handleResponseDocOptions?.(docOptions);\n if (this._defaultPlacement() === 'content') {\n docOptions.target = this._firstExpandedTarget(docOptions.target);\n }\n return new up.ResponseDoc(docOptions);\n }\n _improveOptionsFromResponseDoc() {\n if (this._preview)\n return;\n let responseDoc = this._getResponseDoc();\n if (this.options.fragment) {\n this.options.target ||= responseDoc.rootSelector();\n }\n this.options.title = this.improveHistoryValue(this.options.title, responseDoc.title);\n this.options.metaTags = this.improveHistoryValue(this.options.metaTags, responseDoc.metaTags);\n }\n _defaultPlacement() {\n if (!this.options.document && !this.options.fragment) {\n return 'content';\n }\n }\n _firstExpandedTarget(target) {\n let layer = this._layers[0] || up.layer.root;\n return this._expandTargets(target || ':main', layer)[0];\n }\n getPreflightProps(opts = {}) {\n const getPlanProps = plan => plan.getPreflightProps();\n return this._seekPlan(getPlanProps) || opts.optional || this._cannotMatchPreflightTarget();\n }\n _cannotMatchPreflightTarget() {\n this._cannotMatchTarget('Could not find target in current page');\n }\n _cannotMatchPostflightTarget() {\n this._cannotMatchTarget('Could not find common target in current page and response');\n }\n _cannotMatchTarget(reason) {\n if (this._getPlans().length) {\n const planTargets = u.uniq(u.map(this._getPlans(), 'target'));\n const humanizedLayerOption = up.layer.optionToString(this.options.layer);\n throw new up.CannotMatch([reason + \" (tried selectors %o in %s)\", planTargets, humanizedLayerOption]);\n }\n else if (this._layers.length === 0) {\n this._cannotMatchLayer();\n }\n else if (this.options.failPrefixForced) {\n throw new up.CannotMatch('No target selector given for failed responses (https://unpoly.com/failed-responses)');\n }\n else {\n throw new up.CannotMatch('No target selector given');\n }\n }\n _cannotMatchLayer() {\n throw new up.CannotMatch('Could not find a layer to render in. You may have passed an unmatchable layer reference, or a detached element.');\n }\n _seekPlan(fn) {\n for (let plan of this._getPlans()) {\n try {\n return fn(plan);\n }\n catch (error) {\n if (this._isApplicablePlanError(error)) {\n throw error;\n }\n }\n }\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _getPlans: true,\n _getResponseDoc: true,\n getPreflightProps: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 35 */\n/***/ (() => {\n\nconst u = up.util;\nup.CompilerPass = class CompilerPass {\n constructor(root, compilers, { layer, data, dataMap, meta }) {\n layer ||= up.layer.get(root) || up.layer.current;\n this._root = root;\n this._compilers = compilers;\n this._layer = layer;\n this._data = data;\n this._dataMap = dataMap;\n meta ||= {};\n meta.layer = layer;\n this._meta = meta;\n }\n run() {\n this._layer.asCurrent(() => {\n this.setCompileData();\n for (let compiler of this._compilers) {\n this._runCompiler(compiler);\n }\n });\n }\n setCompileData() {\n if (this._data) {\n this._root.upCompileData = this._data;\n }\n if (this._dataMap) {\n for (let selector in this._dataMap) {\n for (let match of this._select(selector)) {\n match.upCompileData = this._dataMap[selector];\n }\n }\n }\n }\n _runCompiler(compiler) {\n const matches = this._selectOnce(compiler);\n if (!matches.length) {\n return;\n }\n if (!compiler.isDefault) {\n up.puts('up.hello()', 'Compiling %d\u00D7 \"%s\" on %s', matches.length, compiler.selector, this._layer);\n }\n if (compiler.batch) {\n this._compileBatch(compiler, matches);\n }\n else {\n for (let match of matches) {\n this._compileOneElement(compiler, match);\n }\n }\n return up.migrate.postCompile?.(matches, compiler);\n }\n _compileOneElement(compiler, element) {\n const compileArgs = [element];\n if (compiler.length !== 1) {\n const data = up.script.data(element);\n compileArgs.push(data, this._meta);\n }\n const result = this._applyCompilerFunction(compiler, element, compileArgs);\n let destructorOrDestructors = this._destructorPresence(result);\n if (destructorOrDestructors) {\n up.destructor(element, destructorOrDestructors);\n }\n }\n _compileBatch(compiler, elements) {\n const compileArgs = [elements];\n if (compiler.length !== 1) {\n const dataList = u.map(elements, up.script.data);\n compileArgs.push(dataList, this._meta);\n }\n const result = this._applyCompilerFunction(compiler, elements, compileArgs);\n if (this._destructorPresence(result)) {\n up.fail('Compilers with { batch: true } cannot return destructors');\n }\n }\n _applyCompilerFunction(compiler, elementOrElements, compileArgs) {\n return up.error.guard(() => compiler.apply(elementOrElements, compileArgs));\n }\n _destructorPresence(result) {\n if (u.isFunction(result) || (u.isArray(result) && (u.every(result, u.isFunction)))) {\n return result;\n }\n }\n _select(selector) {\n return up.fragment.subtree(this._root, u.evalOption(selector), { layer: this._layer });\n }\n _selectOnce(compiler) {\n let matches = this._select(compiler.selector);\n return u.filter(matches, (element) => {\n let appliedCompilers = (element.upAppliedCompilers ||= new Set());\n if (!appliedCompilers.has(compiler)) {\n appliedCompilers.add(compiler);\n return true;\n }\n });\n }\n};\n\n\n/***/ }),\n/* 36 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.CSSTransition = class CSSTransition {\n constructor(element, lastFrameKebab, options) {\n this._element = element;\n this._lastFrameKebab = lastFrameKebab;\n this._lastFrameKeysKebab = Object.keys(this._lastFrameKebab);\n if (u.some(this._lastFrameKeysKebab, key => key.match(/A-Z/))) {\n up.fail('Animation keys must be kebab-case');\n }\n this._finishEvent = options.finishEvent;\n this._duration = options.duration;\n this._easing = options.easing;\n this._finished = false;\n }\n start() {\n if (this._lastFrameKeysKebab.length === 0) {\n this._finished = true;\n return Promise.resolve();\n }\n this._deferred = u.newDeferred();\n this._pauseOldTransition();\n this._startTime = new Date();\n this._startFallbackTimer();\n this._listenToFinishEvent();\n this._listenToTransitionEnd();\n this._startMotion();\n return this._deferred;\n }\n _listenToFinishEvent() {\n if (this._finishEvent) {\n this._stopListenToFinishEvent = up.on(this._element, this._finishEvent, this._onFinishEvent.bind(this));\n }\n }\n _onFinishEvent(event) {\n event.stopPropagation();\n this._finish();\n }\n _startFallbackTimer() {\n const timingTolerance = 100;\n this._fallbackTimer = u.timer((this._duration + timingTolerance), () => {\n this._finish();\n });\n }\n _stopFallbackTimer() {\n clearTimeout(this._fallbackTimer);\n }\n _listenToTransitionEnd() {\n this._stopListenToTransitionEnd = up.on(this._element, 'transitionend', this._onTransitionEnd.bind(this));\n }\n _onTransitionEnd(event) {\n if (event.target !== this._element) {\n return;\n }\n const elapsed = new Date() - this._startTime;\n if (elapsed <= (0.25 * this._duration)) {\n return;\n }\n const completedPropertyKebab = event.propertyName;\n if (!u.contains(this._lastFrameKeysKebab, completedPropertyKebab)) {\n return;\n }\n this._finish();\n }\n _finish() {\n if (this._finished) {\n return;\n }\n this._finished = true;\n this._stopFallbackTimer();\n this._stopListenToFinishEvent?.();\n this._stopListenToTransitionEnd?.();\n e.concludeCSSTransition(this._element);\n this._resumeOldTransition();\n this._deferred.resolve();\n }\n _pauseOldTransition() {\n const oldTransition = e.style(this._element, [\n 'transitionProperty',\n 'transitionDuration',\n 'transitionDelay',\n 'transitionTimingFunction'\n ]);\n if (e.hasCSSTransition(oldTransition)) {\n if (oldTransition.transitionProperty !== 'all') {\n const oldTransitionProperties = oldTransition.transitionProperty.split(/\\s*,\\s*/);\n const oldTransitionFrameKebab = e.style(this._element, oldTransitionProperties);\n this._setOldTransitionTargetFrame = e.setTemporaryStyle(this._element, oldTransitionFrameKebab);\n }\n this._setOldTransition = e.concludeCSSTransition(this._element);\n }\n }\n _resumeOldTransition() {\n this._setOldTransitionTargetFrame?.();\n this._setOldTransition?.();\n }\n _startMotion() {\n e.setStyle(this._element, {\n transitionProperty: Object.keys(this._lastFrameKebab).join(', '),\n transitionDuration: `${this._duration}ms`,\n transitionTimingFunction: this._easing\n });\n e.setStyle(this._element, this._lastFrameKebab);\n }\n};\n\n\n/***/ }),\n/* 37 */\n/***/ (() => {\n\nconst u = up.util;\nup.DestructorPass = class DestructorPass {\n constructor(fragment, options) {\n this._fragment = fragment;\n this._options = options;\n }\n run() {\n for (let cleanable of this._selectCleanables()) {\n let destructors = u.pluckKey(cleanable, 'upDestructors');\n if (destructors) {\n for (let destructor of destructors) {\n this._applyDestructorFunction(destructor, cleanable);\n }\n }\n cleanable.classList.remove('up-can-clean');\n }\n }\n _selectCleanables() {\n const selectOptions = { ...this._options, destroying: true };\n return up.fragment.subtree(this._fragment, '.up-can-clean', selectOptions);\n }\n _applyDestructorFunction(destructor, element) {\n up.error.guard(() => destructor(element));\n }\n};\n\n\n/***/ }),\n/* 38 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.EventEmitter = class EventEmitter extends up.Record {\n keys() {\n return [\n 'target',\n 'event',\n 'baseLayer',\n 'callback',\n 'log',\n 'ensureBubbles',\n ];\n }\n emit() {\n this._logEmission();\n if (this.baseLayer) {\n this.baseLayer.asCurrent(() => this._dispatchEvent());\n }\n else {\n this._dispatchEvent();\n }\n return this.event;\n }\n _dispatchEvent() {\n this.target.dispatchEvent(this.event);\n if (this.ensureBubbles && !this.target.isConnected) {\n document.dispatchEvent(this.event);\n }\n up.error.guard(() => this.callback?.(this.event));\n }\n assertEmitted() {\n const event = this.emit();\n if (event.defaultPrevented) {\n throw new up.Aborted(`Event ${event.type} was prevented`);\n }\n }\n _logEmission() {\n if (!up.log.config.enabled) {\n return;\n }\n let message = this.log;\n let messageArgs;\n if (u.isArray(message)) {\n [message, ...messageArgs] = message;\n }\n else {\n messageArgs = [];\n }\n const { type } = this.event;\n if (u.isString(message)) {\n up.puts(type, message, ...messageArgs);\n }\n else if (message !== false) {\n up.puts(type, `Event ${type}`);\n }\n }\n static fromEmitArgs(args, defaults = {}) {\n let options = u.extractOptions(args);\n options = u.merge(defaults, options);\n if (u.isElementish(args[0])) {\n options.target = e.get(args.shift());\n }\n else if (args[0] instanceof up.Layer) {\n options.layer = args.shift();\n }\n let layer;\n if (u.isGiven(options.layer)) {\n layer = up.layer.get(options.layer);\n options.target ||= layer.element;\n options.baseLayer ||= layer;\n }\n if (options.baseLayer) {\n options.baseLayer = up.layer.get(options.baseLayer);\n }\n if (u.isString(options.target)) {\n options.target = up.fragment.get(options.target, { layer: options.layer });\n }\n else if (!options.target) {\n options.target = document;\n }\n if (args[0]?.preventDefault) {\n options.event = args[0];\n options.log ??= args[0].log;\n }\n else if (u.isString(args[0])) {\n options.event = up.event.build(args[0], options);\n }\n else {\n options.event = up.event.build(options);\n }\n return new (this)(options);\n }\n};\n\n\n/***/ }),\n/* 39 */\n/***/ (() => {\n\nconst u = up.util;\nup.EventListener = class EventListener extends up.Record {\n keys() {\n return [\n 'element',\n 'eventType',\n 'selector',\n 'callback',\n 'guard',\n 'baseLayer',\n 'passive',\n 'once',\n 'capture',\n 'beforeBoot',\n ];\n }\n constructor(attributes) {\n super(attributes);\n this._key = this.constructor._buildKey(attributes);\n this.isDefault = up.framework.evaling;\n this.beforeBoot ??= (this.eventType.indexOf('up:framework:') === 0);\n this.nativeCallback = this.nativeCallback.bind(this);\n }\n bind() {\n const map = (this.element.upEventListeners ||= {});\n if (map[this._key]) {\n up.fail('up.on(): The %o callback %o cannot be registered more than once', this.eventType, this.callback);\n }\n map[this._key] = this;\n this.element.addEventListener(...this._addListenerArg());\n }\n _addListenerArg() {\n let options = u.compactObject(u.pick(this, ['once', 'passive', 'capture']));\n return [this.eventType, this.nativeCallback, options];\n }\n unbind() {\n let map = this.element.upEventListeners;\n if (map) {\n delete map[this._key];\n }\n this.element.removeEventListener(...this._addListenerArg());\n }\n nativeCallback(event) {\n if (up.framework.beforeBoot && !this.beforeBoot) {\n return;\n }\n let element = event.target;\n if (this.selector) {\n element = element.closest(u.evalOption(this.selector));\n }\n if (this.guard && !this.guard(event)) {\n return;\n }\n if (element) {\n const args = [event, element];\n const expectedArgCount = this.callback.length;\n if (expectedArgCount !== 1 && expectedArgCount !== 2) {\n const data = up.script.data(element);\n args.push(data);\n }\n if (this.eventType === 'click' && element.disabled) {\n return;\n }\n const applyCallback = this.callback.bind(element, ...args);\n if (this.baseLayer) {\n this.baseLayer.asCurrent(applyCallback);\n }\n else {\n applyCallback();\n }\n }\n }\n static fromElement(attributes) {\n let map = attributes.element.upEventListeners;\n if (map) {\n const key = this._buildKey(attributes);\n return map[key];\n }\n }\n static _buildKey(attributes) {\n attributes.callback.upUid ||= u.uid();\n return [\n attributes.eventType,\n attributes.selector,\n attributes.callback.upUid\n ].join('|');\n }\n static allNonDefault(element) {\n let map = element.upEventListeners;\n if (map) {\n const listeners = Object.values(map);\n return u.reject(listeners, 'isDefault');\n }\n else {\n return [];\n }\n }\n};\n\n\n/***/ }),\n/* 40 */\n/***/ (() => {\n\nconst u = up.util;\nup.EventListenerGroup = class EventListenerGroup extends up.Record {\n keys() {\n return [\n 'elements',\n 'eventTypes',\n 'selector',\n 'callback',\n 'guard',\n 'baseLayer',\n 'passive',\n 'once',\n 'capture',\n 'beforeBoot',\n ];\n }\n bind() {\n const unbindFns = [];\n this._eachListenerAttributes(function (attrs) {\n const listener = new up.EventListener(attrs);\n listener.bind();\n return unbindFns.push(listener.unbind.bind(listener));\n });\n return u.sequence(unbindFns);\n }\n _eachListenerAttributes(fn) {\n for (let element of this.elements) {\n for (let eventType of this.eventTypes) {\n fn(this._listenerAttributes(element, eventType));\n }\n }\n }\n _listenerAttributes(element, eventType) {\n return { ...this.attributes(), element, eventType };\n }\n unbind() {\n this._eachListenerAttributes(function (attrs) {\n let listener = up.EventListener.fromElement(attrs);\n if (listener) {\n listener.unbind();\n }\n });\n }\n static fromBindArgs(args, defaults) {\n args = u.copy(args);\n const callback = args.pop();\n let elements;\n if (args[0].addEventListener) {\n elements = [args.shift()];\n }\n else if (u.isJQuery(args[0]) || (u.isList(args[0]) && args[0][0].addEventListener)) {\n elements = args.shift();\n }\n else {\n elements = [document];\n }\n let eventTypes = u.parseTokens(args.shift());\n let fixTypes = up.migrate.fixEventTypes;\n if (fixTypes) {\n eventTypes = fixTypes(eventTypes);\n }\n const options = u.extractOptions(args);\n const selector = args[0];\n const attributes = { elements, eventTypes, selector, callback, ...options, ...defaults };\n return new (this)(attributes);\n }\n};\n\n\n/***/ }),\n/* 41 */\n/***/ (() => {\n\nconst u = up.util;\nup.FieldWatcher = class FieldWatcher {\n constructor(root, options, callback) {\n this._options = options;\n this._root = root;\n this._scope = up.form.getScope(root);\n this._callback = callback;\n this._batch = options.batch;\n this._abortable = options.abortable;\n }\n start() {\n this._scheduledValues = null;\n this._processedValues = this._readFieldValues();\n this._currentTimer = null;\n this._callbackRunning = false;\n this._unbindFns = [];\n this._watchFieldsWithin(this._root);\n this._root.addEventListener('up:fragment:inserted', ({ target }) => {\n if (target !== this._root)\n this._watchFieldsWithin(target);\n });\n this._unbindFns.push(up.fragment.onAborted(this._scope, () => this._abort()));\n this._unbindFns.push(up.on(this._scope, 'reset', () => this._onFormReset()));\n }\n stop() {\n this._abort();\n for (let unbindFn of this._unbindFns)\n unbindFn();\n }\n _fieldOptions(field) {\n let rootOptions = u.copy(this._options);\n return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });\n }\n _watchFieldsWithin(container) {\n for (let field of up.form.fields(container)) {\n this._watchField(field);\n }\n }\n _watchField(field) {\n let fieldOptions = this._fieldOptions(field);\n this._unbindFns.push(up.on(field, fieldOptions.event, () => this._check(fieldOptions)));\n }\n _abort() {\n this._scheduledValues = null;\n }\n _scheduleValues(values, fieldOptions) {\n this._scheduledValues = values;\n this._scheduledFieldOptions = fieldOptions;\n let delay = fieldOptions.delay || 0;\n clearTimeout(this._currentTimer);\n this._currentTimer = u.timer(delay, () => {\n this._currentTimer = null;\n this._requestCallback();\n });\n }\n _isNewValues(values) {\n return !u.isEqual(values, this._processedValues) && !u.isEqual(this._scheduledValues, values);\n }\n async _requestCallback() {\n if (!this._scheduledValues)\n return;\n if (this._callbackRunning)\n return;\n if (this._currentTimer)\n return;\n if (!this._scope.isConnected)\n return;\n let fieldOptions = this._scheduledFieldOptions;\n const diff = this._changedValues(this._processedValues, this._scheduledValues);\n this._processedValues = this._scheduledValues;\n this._scheduledValues = null;\n this._callbackRunning = true;\n this._scheduledFieldOptions = null;\n let callbackOptions = { ...fieldOptions, disable: false };\n const callbackReturnValues = [];\n if (this._batch) {\n callbackReturnValues.push(this._runCallback(diff, callbackOptions));\n }\n else {\n for (let name in diff) {\n const value = diff[name];\n callbackReturnValues.push(this._runCallback(value, name, callbackOptions));\n }\n }\n if (u.some(callbackReturnValues, u.isPromise)) {\n let callbackDone = Promise.allSettled(callbackReturnValues);\n up.form.disableWhile(callbackDone, fieldOptions);\n await callbackDone;\n }\n this._callbackRunning = false;\n this._requestCallback();\n }\n _runCallback(...args) {\n return up.error.guard(() => this._callback(...args));\n }\n _changedValues(previous, next) {\n const changes = {};\n let keys = Object.keys(previous);\n keys = keys.concat(Object.keys(next));\n keys = u.uniq(keys);\n for (let key of keys) {\n const previousValue = previous[key];\n const nextValue = next[key];\n if (!u.isEqual(previousValue, nextValue)) {\n changes[key] = nextValue;\n }\n }\n return changes;\n }\n _readFieldValues() {\n return up.Params.fromContainer(this._root).toObject();\n }\n _check(fieldOptions = {}) {\n const values = this._readFieldValues();\n if (this._isNewValues(values)) {\n this._scheduleValues(values, fieldOptions);\n }\n }\n _onFormReset() {\n u.task(() => this._check());\n }\n};\n\n\n/***/ }),\n/* 42 */\n/***/ (() => {\n\nconst u = up.util;\nup.FormValidator = class FormValidator {\n constructor(form) {\n this._form = form;\n this._dirtySolutions = [];\n this._nextRenderTimer = null;\n this._rendering = false;\n this._resetNextRenderPromise();\n this._honorAbort();\n }\n _honorAbort() {\n up.fragment.onAborted(this._form, (event) => this._onAborted(event));\n }\n _onAborted(event) {\n if (this._dirtySolutions.length) {\n this._dirtySolutions = [];\n this._nextRenderPromise.reject(new up.Aborted(event.reason));\n this._resetNextRenderPromise();\n }\n }\n _resetNextRenderPromise() {\n this._nextRenderPromise = u.newDeferred();\n }\n watchContainer(fieldOrForm) {\n let { event } = this._originOptions(fieldOrForm);\n let guard = () => up.fragment.isAlive(fieldOrForm);\n let callback = () => up.error.muteUncriticalRejection(this.validate({ origin: fieldOrForm }));\n up.on(fieldOrForm, event, { guard }, callback);\n }\n validate(options = {}) {\n let solutions = this._getSolutions(options);\n this._dirtySolutions.push(...solutions);\n this._scheduleNextRender();\n return this._nextRenderPromise;\n }\n _getSolutions(options) {\n let solutions = this._getTargetSelectorSolutions(options)\n || this._getFieldSolutions(options)\n || this._getElementSolutions(options.origin);\n for (let solution of solutions) {\n solution.renderOptions = this._originOptions(solution.origin, options);\n solution.target = up.fragment.resolveOrigin(solution.target, solution);\n }\n return solutions;\n }\n _getFieldSolutions({ origin, ...options }) {\n if (up.form.isField(origin)) {\n return this._getValidateAttrSolutions(origin) || this._getFormGroupSolutions(origin, options);\n }\n }\n _getFormGroupSolutions(field, { formGroup = true }) {\n if (!formGroup)\n return;\n let solution = up.form.groupSolution(field);\n if (solution) {\n up.puts('up.validate()', 'Validating form group of field %o', field);\n return [solution];\n }\n }\n _getTargetSelectorSolutions({ target, origin }) {\n if (u.isString(target) && target) {\n up.puts('up.validate()', 'Validating target \"%s\"', target);\n let simpleSelectors = up.fragment.splitTarget(target);\n return u.compact(simpleSelectors.map(function (simpleSelector) {\n let element = up.fragment.get(simpleSelector, { origin });\n if (element) {\n return {\n element,\n target: simpleSelector,\n origin\n };\n }\n else {\n up.fail('Validation target \"%s\" does not match an element', simpleSelector);\n }\n }));\n }\n }\n _getElementSolutions(element) {\n up.puts('up.validate()', 'Validating element %o', element);\n return [{\n element,\n target: up.fragment.toTarget(element),\n origin: element\n }];\n }\n _getValidateAttrSolutions(field) {\n let containerWithAttr = field.closest('[up-validate]');\n if (containerWithAttr) {\n let target = containerWithAttr.getAttribute('up-validate');\n return this._getTargetSelectorSolutions({ target, origin: field });\n }\n }\n _originOptions(element, overrideOptions) {\n return up.form.watchOptions(element, overrideOptions, { defaults: { event: 'change' } });\n }\n _scheduleNextRender() {\n let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);\n let shortestDelay = Math.min(...solutionDelays) || 0;\n clearTimeout(this._nextRenderTimer);\n this._nextRenderTimer = u.timer(shortestDelay, () => {\n this._nextRenderTimer = null;\n this._renderDirtySolutions();\n });\n }\n _renderDirtySolutions() {\n up.error.muteUncriticalRejection(this._doRenderDirtySolutions());\n }\n async _doRenderDirtySolutions() {\n if (!this._dirtySolutions.length)\n return;\n if (this._rendering)\n return;\n if (this._nextRenderTimer)\n return;\n let dirtySolutions = this._dirtySolutions;\n this._dirtySolutions = [];\n let dirtyOrigins = u.map(dirtySolutions, 'origin');\n let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);\n let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));\n let dataMap = this._buildDataMap(dirtySolutions);\n let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');\n let options = u.mergeDefined(...dirtyRenderOptionsList, { dataMap }, up.form.destinationOptions(this._form));\n options.target = u.map(dirtySolutions, 'target').join(', ');\n options.feedback = u.some(dirtyRenderOptionsList, 'feedback');\n options.origin = this._form;\n options.focus ??= 'keep';\n options.failOptions = false;\n options.defaultMaybe = true;\n options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));\n options.headers = u.merge(...u.map(dirtyRenderOptionsList, 'headers'));\n this._addValidateHeader(options.headers, dirtyNames);\n options.guardEvent = up.event.build('up:form:validate', {\n fields: dirtyFields,\n log: 'Validating form',\n params: options.params\n });\n this._rendering = true;\n let renderingPromise = this._nextRenderPromise;\n this._resetNextRenderPromise();\n options.disable = false;\n for (let solution of dirtySolutions) {\n up.form.disableWhile(renderingPromise, {\n disable: solution.renderOptions.disable,\n origin: solution.origin,\n });\n }\n try {\n renderingPromise.resolve(up.render(options));\n await renderingPromise;\n }\n finally {\n this._rendering = false;\n this._renderDirtySolutions();\n }\n }\n _addValidateHeader(headers, names) {\n let key = up.protocol.headerize('validate');\n let value = names.join(' ');\n if (!value || value.length > up.protocol.config.maxHeaderSize)\n value = ':unknown';\n headers[key] = value;\n }\n _buildDataMap(solutions) {\n let dataMap = {};\n for (let solution of solutions) {\n let data = u.pluckKey(solution.renderOptions, 'data');\n let keepData = u.pluckKey(solution.renderOptions, 'keepData');\n if (keepData) {\n data = up.data(solution.element);\n }\n if (data) {\n dataMap[solution.target] = data;\n }\n }\n return dataMap;\n }\n static forElement(element) {\n let form = up.form.get(element);\n return form.upFormValidator ||= new this(form);\n }\n};\n\n\n/***/ }),\n/* 43 */\n/***/ (() => {\n\nup.FocusCapsule = class FocusCapsule {\n constructor(target, cursorProps) {\n this._target = target;\n this._cursorProps = cursorProps;\n }\n restore(layer, options) {\n let rediscoveredElement = up.fragment.get(this._target, { layer });\n if (rediscoveredElement) {\n up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);\n up.focus(rediscoveredElement, options);\n return true;\n }\n }\n static preserve(layer) {\n let focusedElement = up.viewport.focusedElementWithin(layer.element);\n if (!focusedElement)\n return;\n let target = up.fragment.tryToTarget(focusedElement);\n if (!target)\n return;\n const cursorProps = up.viewport.copyCursorProps(focusedElement);\n return new this(target, cursorProps);\n }\n};\n\n\n/***/ }),\n/* 44 */\n/***/ (() => {\n\nconst u = up.util;\nup.FragmentProcessor = class FragmentProcessor extends up.Record {\n keys() {\n return [\n 'fragment',\n 'autoMeans',\n 'origin',\n 'layer'\n ];\n }\n process(opt) {\n let preprocessed = this.preprocess(opt);\n return this.tryProcess(preprocessed);\n }\n preprocess(opt) {\n return u.parseTokens(opt, { separator: 'or' });\n }\n tryProcess(opt) {\n if (u.isArray(opt)) {\n return this.processArray(opt);\n }\n if (u.isFunction(opt)) {\n let result = up.error.guard(() => opt(this.fragment, this.attributes()));\n return this.tryProcess(result);\n }\n if (u.isElement(opt)) {\n return this.processElement(opt);\n }\n if (u.isString(opt)) {\n if (opt === 'auto') {\n return this.tryProcess(this.autoMeans);\n }\n let match = opt.match(/^(.+?)-if-(.+?)$/);\n if (match) {\n return this.resolveCondition(match[2]) && this.process(match[1]);\n }\n }\n return this.processPrimitive(opt);\n }\n processArray(array) {\n return u.find(array, opt => this.tryProcess(opt));\n }\n resolveCondition(condition) {\n if (condition === 'main') {\n return this.fragment && up.fragment.contains(this.fragment, ':main');\n }\n }\n findSelector(selector) {\n const lookupOpts = { layer: this.layer, origin: this.origin };\n let matchWithinFragment = this.fragment && up.fragment.get(this.fragment, selector, lookupOpts);\n let match = matchWithinFragment || up.fragment.get(selector, lookupOpts);\n if (match) {\n return match;\n }\n else {\n up.warn('up.render()', 'Could not find an element matching \"%s\"', selector);\n }\n }\n};\n\n\n/***/ }),\n/* 45 */\n/***/ (() => {\n\nconst u = up.util;\nconst DESCENDANT_SELECTOR = /^([^ >+(]+) (.+)$/;\nup.FragmentFinder = class FragmentFinder {\n constructor(options) {\n this._options = options;\n this._origin = options.origin;\n this._selector = options.selector;\n this._document = options.document || window.document;\n this._match = options.match ?? up.fragment.config.match;\n this._preferOldElements = options.preferOldElements;\n }\n find() {\n return this._findInPreferredElements() || this._findInRegion() || this._findFirst();\n }\n _findInPreferredElements() {\n if (this._preferOldElements) {\n return this._preferOldElements.find((preferOldElement) => this._document.contains(preferOldElement) && up.fragment.matches(preferOldElement, this._selector));\n }\n }\n _findInRegion() {\n if (this._match === 'region' && !up.fragment.containsMainPseudo(this._selector) && this._origin?.isConnected) {\n return this._findClosest() || this._findDescendantInRegion();\n }\n }\n _findClosest() {\n return up.fragment.closest(this._origin, this._selector, this._options);\n }\n _findDescendantInRegion() {\n let simpleSelectors = up.fragment.splitTarget(this._selector);\n return u.findResult(simpleSelectors, (simpleSelector) => {\n let parts = simpleSelector.match(DESCENDANT_SELECTOR);\n if (parts) {\n let parent = up.fragment.closest(this._origin, parts[1], this._options);\n if (parent) {\n return up.fragment.getDumb(parent, parts[2]);\n }\n }\n });\n }\n _findFirst() {\n return up.fragment.getDumb(this._document, this._selector, this._options);\n }\n};\n\n\n/***/ }),\n/* 46 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nconst PREVENT_SCROLL_OPTIONS = { preventScroll: true };\nup.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {\n keys() {\n return super.keys().concat([\n 'hash',\n 'focusCapsule',\n 'inputDevice',\n ]);\n }\n processPrimitive(opt) {\n switch (opt) {\n case 'keep':\n return this._restoreLostFocus();\n case 'restore':\n return this._restorePreviousFocusForLocation();\n case 'target':\n case true:\n return this._focusElement(this.fragment);\n case 'layer':\n return this._focusElement(this.layer.getFocusElement());\n case 'main':\n return this._focusSelector(':main');\n case 'hash':\n return this._focusHash();\n case 'autofocus':\n return this._autofocus();\n default:\n if (u.isString(opt)) {\n return this._focusSelector(opt);\n }\n }\n }\n processElement(element) {\n return this._focusElement(element);\n }\n resolveCondition(condition) {\n if (condition === 'lost') {\n return this._wasFocusLost();\n }\n else {\n return super.resolveCondition(condition);\n }\n }\n _focusSelector(selector) {\n let match = this.findSelector(selector);\n return this._focusElement(match);\n }\n _restoreLostFocus() {\n if (this._wasFocusLost()) {\n return this.focusCapsule?.restore(this.layer, PREVENT_SCROLL_OPTIONS);\n }\n }\n _restorePreviousFocusForLocation() {\n return up.viewport.restoreFocus({ layer: this.layer });\n }\n _autofocus() {\n let autofocusElement = this.fragment && e.subtree(this.fragment, '[autofocus]')[0];\n if (autofocusElement) {\n return this._focusElement(autofocusElement);\n }\n }\n _focusElement(element) {\n if (element) {\n up.focus(element, { force: true, ...PREVENT_SCROLL_OPTIONS, inputDevice: this.inputDevice });\n return true;\n }\n }\n _focusHash() {\n let hashTarget = up.viewport.firstHashTarget(this.hash, { layer: this.layer });\n if (hashTarget) {\n return this._focusElement(hashTarget);\n }\n }\n _wasFocusLost() {\n return !this.layer.hasFocus();\n }\n};\n\n\n/***/ }),\n/* 47 */\n/***/ (() => {\n\nconst e = up.element;\nup.FragmentPolling = class FragmentPolling {\n constructor(fragment) {\n this._options = up.radio.pollOptions(fragment);\n this._fragment = fragment;\n up.destructor(fragment, this._onFragmentDestroyed.bind(this));\n up.fragment.onAborted(fragment, this._onFragmentAborted.bind(this));\n this._state = 'initialized';\n this._abortable = true;\n this._loading = false;\n this._satisfyInterval();\n }\n static forFragment(fragment) {\n return fragment.upPolling ||= new this(fragment);\n }\n onPollAttributeObserved() {\n this._start();\n }\n _onFragmentDestroyed() {\n this._stop();\n }\n _start(options) {\n Object.assign(this._options, options);\n if (this._state !== 'started') {\n if (!up.fragment.isTargetable(this._fragment)) {\n up.warn('[up-poll]', 'Cannot poll untargetable fragment %o', this._fragment);\n return;\n }\n this._state = 'started';\n this._ensureEventsBound();\n this._scheduleRemainingTime();\n }\n }\n _stop() {\n if (this._state === 'started') {\n this._clearReloadTimer();\n this._state = 'stopped';\n this.unbindEvents?.();\n }\n }\n forceStart(options) {\n Object.assign(this._options, options);\n this.forceStarted = true;\n this._start();\n }\n forceStop() {\n this._stop();\n this.forceStarted = false;\n }\n _ensureEventsBound() {\n if (!this.unbindEvents) {\n this.unbindEvents = up.on('visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted', this._onVisibilityChange.bind(this));\n }\n }\n _onVisibilityChange() {\n if (this._isFragmentVisible()) {\n this._scheduleRemainingTime();\n }\n else {\n }\n }\n _isFragmentVisible() {\n return (!document.hidden) &&\n (this._options.ifLayer === 'any' || this._isOnFrontLayer());\n }\n _clearReloadTimer() {\n clearTimeout(this.reloadTimer);\n this.reloadTimer = null;\n }\n _scheduleRemainingTime() {\n if (!this.reloadTimer && !this._loading) {\n this._clearReloadTimer();\n this.reloadTimer = setTimeout(this._onTimerReached.bind(this), this._getRemainingDelay());\n }\n }\n _onTimerReached() {\n this.reloadTimer = null;\n this._tryReload();\n }\n _tryReload() {\n if (this._state !== 'started') {\n return;\n }\n if (!this._isFragmentVisible()) {\n up.puts('[up-poll]', 'Will not poll hidden fragment');\n return;\n }\n if (up.emit(this._fragment, 'up:fragment:poll', { log: ['Polling fragment', this._fragment] }).defaultPrevented) {\n up.puts('[up-poll]', 'User prevented up:fragment:poll event');\n this._satisfyInterval();\n this._scheduleRemainingTime();\n return;\n }\n this._reloadNow();\n }\n _getFullDelay() {\n return this._options.interval ?? e.numberAttr(this._fragment, 'up-interval') ?? up.radio.config.pollInterval;\n }\n _getRemainingDelay() {\n return Math.max(this._getFullDelay() - this._getFragmentAge(), 0);\n }\n _getFragmentAge() {\n return new Date() - this._lastAttempt;\n }\n _isOnFrontLayer() {\n this.layer ||= up.layer.get(this._fragment);\n return this.layer?.isFront?.();\n }\n _reloadNow() {\n this._clearReloadTimer();\n let reloadOptions = {\n url: this._options.url,\n fail: false,\n background: true,\n };\n let oldAbortable = this._abortable;\n try {\n this._abortable = false;\n this._loading = true;\n up.reload(this._fragment, reloadOptions).then(this._onReloadSuccess.bind(this), this._onReloadFailure.bind(this));\n }\n finally {\n this._abortable = oldAbortable;\n }\n }\n _onFragmentAborted({ newLayer }) {\n if (this._abortable && !newLayer) {\n this._stop();\n }\n }\n _onReloadSuccess({ fragment }) {\n this._loading = false;\n this._satisfyInterval();\n if (fragment) {\n this._onFragmentSwapped(fragment);\n }\n else {\n this._scheduleRemainingTime();\n }\n }\n _onFragmentSwapped(newFragment) {\n this._stop();\n if (this.forceStarted && up.fragment.matches(this._fragment, newFragment)) {\n this.constructor.forFragment(newFragment).forceStart(this._options);\n }\n }\n _onReloadFailure(reason) {\n this._loading = false;\n this._satisfyInterval();\n this._scheduleRemainingTime();\n up.error.throwCritical(reason);\n }\n _satisfyInterval() {\n this._lastAttempt = new Date();\n }\n};\n\n\n/***/ }),\n/* 48 */\n/***/ (() => {\n\nconst u = up.util;\nup.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {\n keys() {\n return super.keys().concat([\n 'hash',\n 'mode',\n 'revealTop',\n 'revealMax',\n 'revealSnap',\n 'scrollBehavior',\n ]);\n }\n processPrimitive(opt) {\n switch (opt) {\n case 'reset':\n return this._reset();\n case 'layer':\n return this._revealLayer();\n case 'main':\n return this._revealSelector(':main');\n case 'restore':\n return this._restore();\n case 'hash':\n return this.hash && up.viewport.revealHash(this.hash, this.attributes());\n case 'target':\n case 'reveal':\n case true:\n return this._revealElement(this.fragment);\n default:\n if (u.isString(opt)) {\n return this._revealSelector(opt);\n }\n }\n }\n processElement(element) {\n return this._revealElement(element);\n }\n _revealElement(element) {\n if (element) {\n up.reveal(element, this.attributes());\n return true;\n }\n }\n _revealSelector(selector) {\n let match = this.findSelector(selector);\n return this._revealElement(match);\n }\n _revealLayer() {\n return this._revealElement(this.layer.getBoxElement());\n }\n _reset() {\n up.viewport.resetScroll({ ...this.attributes(), around: this.fragment });\n return true;\n }\n _restore() {\n return up.viewport.restoreScroll({ ...this.attributes(), around: this.fragment });\n }\n};\n\n\n/***/ }),\n/* 49 */\n/***/ (() => {\n\nconst e = up.element;\nconst u = up.util;\nup.Layer = class Layer extends up.Record {\n keys() {\n return [\n 'element',\n 'stack',\n 'history',\n 'mode',\n 'context',\n 'lastScrollTops',\n 'lastFocusCapsules',\n ];\n }\n defaults() {\n return {\n context: {},\n lastScrollTops: up.viewport.newStateCache(),\n lastFocusCapsules: up.viewport.newStateCache()\n };\n }\n constructor(options = {}) {\n super(options);\n if (!this.mode) {\n throw \"missing { mode } option\";\n }\n }\n setupHandlers() {\n up.link.convertClicks(this);\n }\n teardownHandlers() { }\n mainTargets() {\n return up.layer.mainTargets(this.mode);\n }\n sync() {\n }\n accept() {\n throw new up.NotImplemented();\n }\n dismiss() {\n throw new up.NotImplemented();\n }\n peel(options) {\n this.stack.peel(this, options);\n }\n evalOption(option) {\n return u.evalOption(option, this);\n }\n isCurrent() {\n return this.stack.isCurrent(this);\n }\n isFront() {\n return this.stack.isFront(this);\n }\n isRoot() {\n return this.stack.isRoot(this);\n }\n isOverlay() {\n return this.stack.isOverlay(this);\n }\n isOpen() {\n return this.stack.isOpen(this);\n }\n isClosed() {\n return this.stack.isClosed(this);\n }\n get parent() {\n return this.stack.parentOf(this);\n }\n get child() {\n return this.stack.childOf(this);\n }\n get ancestors() {\n return this.stack.ancestorsOf(this);\n }\n get descendants() {\n return this.stack.descendantsOf(this);\n }\n get subtree() {\n return [this, ...this.descendants];\n }\n get index() {\n return this._index ??= this.stack.indexOf(this);\n }\n getContentElement() {\n return this.contentElement || this.element;\n }\n getBoxElement() {\n return this.boxElement || this.element;\n }\n getFocusElement() {\n return this.getBoxElement();\n }\n getFirstSwappableElement() {\n throw new up.NotImplemented();\n }\n contains(element) {\n return element.closest(up.layer.anySelector()) === this.element;\n }\n on(...args) {\n return this._buildEventListenerGroup(args).bind();\n }\n off(...args) {\n return this._buildEventListenerGroup(args).unbind();\n }\n _buildEventListenerGroup(args) {\n return up.EventListenerGroup.fromBindArgs(args, {\n guard: (event) => this._containsEventTarget(event),\n elements: [this.element],\n baseLayer: this\n });\n }\n _containsEventTarget(event) {\n return this.contains(event.target);\n }\n wasHitByMouseEvent(event) {\n const hittableElement = document.elementFromPoint(event.clientX, event.clientY);\n return !hittableElement || this.contains(hittableElement);\n }\n _buildEventEmitter(args) {\n return up.EventEmitter.fromEmitArgs(args, { layer: this });\n }\n emit(...args) {\n return this._buildEventEmitter(args).emit();\n }\n isDetached() {\n return !this.element.isConnected;\n }\n saveHistory() {\n if (this.history) {\n this.savedTitle = document.title;\n this.savedMetaTags = up.history.findMetaTags();\n this.savedLocation = up.history.location;\n }\n }\n restoreHistory() {\n if (!this.showsLiveHistory()) {\n return;\n }\n if (this.savedLocation) {\n up.history.push(this.savedLocation);\n }\n if (this.savedTitle) {\n document.title = this.savedTitle;\n }\n if (this.savedMetaTags) {\n up.history.updateMetaTags(this.savedMetaTags);\n }\n }\n asCurrent(fn) {\n return this.stack.asCurrent(this, fn);\n }\n updateHistory(options) {\n if (u.isString(options.location)) {\n this.location = options.location;\n }\n if (up.history.config.updateMetaTags && u.isList(options.metaTags)) {\n up.migrate?.warnOfHungryMetaTags?.(options.metaTags);\n this.metaTags = options.metaTags;\n }\n if (u.isString(options.title)) {\n this.title = options.title;\n }\n }\n showsLiveHistory() {\n return this.history && this.isFront();\n }\n get title() {\n if (this.showsLiveHistory()) {\n return document.title;\n }\n else {\n return this.savedTitle;\n }\n }\n set title(title) {\n this.savedTitle = title;\n if (this.showsLiveHistory()) {\n document.title = title;\n }\n }\n get metaTags() {\n if (this.showsLiveHistory()) {\n return up.history.findMetaTags();\n }\n else {\n return this.savedMetaTags;\n }\n }\n set metaTags(metaTags) {\n this.savedMetaTags = metaTags;\n if (this.showsLiveHistory()) {\n up.history.updateMetaTags(metaTags);\n }\n }\n get location() {\n if (this.showsLiveHistory()) {\n return up.history.location;\n }\n else {\n return this.savedLocation;\n }\n }\n set location(location) {\n const previousLocation = this.location;\n location = up.history.normalizeURL(location);\n if (previousLocation !== location || this.opening) {\n this.savedLocation = location;\n if (this.showsLiveHistory()) {\n up.history.push(location);\n }\n if (!this.opening) {\n this.emit('up:layer:location:changed', { location });\n }\n }\n }\n selector(part) {\n return this.constructor.selector(part);\n }\n static selector(_part) {\n throw new up.NotImplemented();\n }\n toString() {\n throw new up.NotImplemented();\n }\n affix(...args) {\n return e.affix(this.getFirstSwappableElement(), ...args);\n }\n [u.isEqual.key](other) {\n return (this.constructor === other.constructor) && (this.element === other.element);\n }\n hasFocus() {\n let focusedElement = document.activeElement;\n return focusedElement !== document.body && this.element.contains(focusedElement);\n }\n reset() {\n Object.assign(this, this.defaults());\n }\n};\n\n\n/***/ }),\n/* 50 */\n/***/ (() => {\n\nconst e = up.element;\nconst u = up.util;\nup.Layer.Overlay = class Overlay extends up.Layer {\n keys() {\n return super.keys().concat([\n 'position',\n 'align',\n 'size',\n 'origin',\n 'class',\n 'backdrop',\n 'openAnimation',\n 'closeAnimation',\n 'openDuration',\n 'closeDuration',\n 'openEasing',\n 'closeEasing',\n 'backdropOpenAnimation',\n 'backdropCloseAnimation',\n 'dismissable',\n 'dismissLabel',\n 'dismissAriaLabel',\n 'onOpened',\n 'onAccept',\n 'onAccepted',\n 'onDismiss',\n 'onDismissed',\n 'acceptEvent',\n 'dismissEvent',\n 'acceptLocation',\n 'dismissLocation',\n 'opening'\n ]);\n }\n constructor(options) {\n super(options);\n if (this.dismissable === true) {\n this.dismissable = ['button', 'key', 'outside'];\n }\n else if (this.dismissable === false) {\n this.dismissable = [];\n }\n else {\n this.dismissable = u.parseTokens(this.dismissable);\n }\n if (this.acceptLocation) {\n this.acceptLocation = new up.URLPattern(this.acceptLocation);\n }\n if (this.dismissLocation) {\n this.dismissLocation = new up.URLPattern(this.dismissLocation);\n }\n }\n callback(name) {\n let fn = this[name];\n if (fn) {\n return fn.bind(this);\n }\n }\n createElement(parentElement) {\n this.nesting ||= this._suggestVisualNesting();\n const elementAttrs = u.compactObject(u.pick(this, ['align', 'position', 'size', 'class', 'nesting']));\n this.element = this.affixPart(parentElement, null, elementAttrs);\n }\n createBackdropElement(parentElement) {\n this.backdropElement = this.affixPart(parentElement, 'backdrop');\n }\n createViewportElement(parentElement) {\n this.viewportElement = this.affixPart(parentElement, 'viewport', { 'up-viewport': '' });\n }\n createBoxElement(parentElement) {\n this.boxElement = this.affixPart(parentElement, 'box');\n }\n createContentElement(parentElement) {\n this.contentElement = this.affixPart(parentElement, 'content');\n }\n setContent(content) {\n this.contentElement.append(content);\n this.onContentSet();\n }\n onContentSet() {\n }\n createDismissElement(parentElement) {\n this.dismissElement = this.affixPart(parentElement, 'dismiss', {\n 'up-dismiss': '\":button\"',\n 'aria-label': this.dismissAriaLabel\n });\n return e.affix(this.dismissElement, 'span[aria-hidden=\"true\"]', { text: this.dismissLabel });\n }\n affixPart(parentElement, part, options = {}) {\n return e.affix(parentElement, this.selector(part), options);\n }\n static selector(part) {\n return u.compact(['up', this.mode, part]).join('-');\n }\n _suggestVisualNesting() {\n const { parent } = this;\n if (this.mode === parent.mode) {\n return 1 + parent._suggestVisualNesting();\n }\n else {\n return 0;\n }\n }\n setupHandlers() {\n super.setupHandlers();\n this.overlayFocus = new up.OverlayFocus(this);\n if (this._supportsDismissMethod('button')) {\n this.createDismissElement(this.getBoxElement());\n }\n if (this._supportsDismissMethod('outside')) {\n if (this.viewportElement) {\n up.on(this.viewportElement, 'up:click', event => {\n if (event.target === this.viewportElement) {\n this._onOutsideClicked(event, true);\n }\n });\n }\n else {\n this.unbindParentClicked = this.parent.on('up:click', (event, element) => {\n if (!up.layer.isWithinForeignOverlay(element)) {\n const originClicked = this.origin && this.origin.contains(element);\n this._onOutsideClicked(event, originClicked);\n }\n });\n }\n }\n if (this._supportsDismissMethod('key')) {\n this.unbindEscapePressed = up.event.onEscape(event => this.onEscapePressed(event));\n }\n this.registerClickCloser('up-accept', (value, closeOptions) => {\n this.accept(value, closeOptions);\n });\n this.registerClickCloser('up-dismiss', (value, closeOptions) => {\n this.dismiss(value, closeOptions);\n });\n up.migrate.registerLayerCloser?.(this);\n this._registerEventCloser(this.acceptEvent, this.accept);\n this._registerEventCloser(this.dismissEvent, this.dismiss);\n this.on('up:click', 'label[for]', (event, label) => this._onLabelClicked(event, label));\n }\n _onLabelClicked(event, label) {\n let id = label.getAttribute('for');\n let fieldSelector = up.form.fieldSelector(e.idSelector(id));\n let fieldsAnywhere = up.fragment.all(fieldSelector, { layer: 'any' });\n let fieldsInLayer = up.fragment.all(fieldSelector, { layer: this });\n if (fieldsAnywhere.length > 1 && fieldsInLayer[0] !== fieldsAnywhere[0]) {\n event.preventDefault();\n const field = fieldsInLayer[0];\n field.focus();\n if (field.matches('input[type=checkbox], input[type=radio]')) {\n field.click();\n }\n }\n }\n _onOutsideClicked(event, halt) {\n up.log.putsEvent(event);\n if (halt)\n up.event.halt(event);\n this.dismiss(':outside', { origin: event.target });\n }\n onEscapePressed(event) {\n if (this.isFront()) {\n let field = up.form.focusedField();\n if (field) {\n field.blur();\n }\n else if (this._supportsDismissMethod('key')) {\n up.event.halt(event, { log: true });\n this.dismiss(':key');\n }\n }\n }\n registerClickCloser(attribute, closeFn) {\n let selector = `[${attribute}]`;\n this.on('up:click', selector, function (event) {\n up.event.halt(event, { log: true });\n const origin = event.target.closest(selector);\n const value = e.jsonAttr(origin, attribute);\n const closeOptions = { origin };\n const parser = new up.OptionsParser(origin, closeOptions);\n parser.booleanOrString('animation');\n parser.string('easing');\n parser.number('duration');\n parser.string('confirm');\n up.error.muteUncriticalSync(() => closeFn(value, closeOptions));\n });\n }\n _registerEventCloser(eventTypes, closeFn) {\n if (!eventTypes) {\n return;\n }\n return this.on(eventTypes, event => {\n event.preventDefault();\n closeFn.call(this, event, { response: event.response });\n });\n }\n tryAcceptForLocation(options) {\n this._tryCloseForLocation(this.acceptLocation, this.accept, options);\n }\n tryDismissForLocation(options) {\n this._tryCloseForLocation(this.dismissLocation, this.dismiss, options);\n }\n _tryCloseForLocation(urlPattern, closeFn, options) {\n let location, resolution;\n if (urlPattern && (location = this.location) && (resolution = urlPattern.recognize(location))) {\n const closeValue = { ...resolution, location };\n closeFn.call(this, closeValue, options);\n }\n }\n teardownHandlers() {\n super.teardownHandlers();\n this.unbindParentClicked?.();\n this.unbindEscapePressed?.();\n this.overlayFocus.teardown();\n }\n destroyElements(options) {\n const animation = () => this.startCloseAnimation(options);\n const onFinished = () => {\n this.onElementsRemoved();\n options.onFinished?.();\n };\n const destroyOptions = { ...options, animation, onFinished, log: false };\n up.destroy(this.element, destroyOptions);\n }\n onElementsRemoved() {\n }\n _startAnimation(options = {}) {\n const boxDone = up.animate(this.getBoxElement(), options.boxAnimation, options);\n let backdropDone;\n if (this.backdrop && !up.motion.isNone(options.boxAnimation)) {\n backdropDone = up.animate(this.backdropElement, options.backdropAnimation, options);\n }\n return Promise.all([boxDone, backdropDone]);\n }\n async startOpenAnimation(options = {}) {\n await this._startAnimation({\n boxAnimation: options.animation ?? this.evalOption(this.openAnimation),\n backdropAnimation: 'fade-in',\n easing: options.easing || this.openEasing,\n duration: options.duration || this.openDuration\n });\n this.wasEverVisible = true;\n }\n startCloseAnimation(options = {}) {\n return this._startAnimation({\n boxAnimation: this.wasEverVisible && (options.animation ?? this.evalOption(this.closeAnimation)),\n backdropAnimation: this.wasEverVisible && 'fade-out',\n easing: options.easing || this.closeEasing,\n duration: options.duration || this.closeDuration\n });\n }\n accept(value = null, options = {}) {\n return this._executeCloseChange('accept', value, options);\n }\n dismiss(value = null, options = {}) {\n return this._executeCloseChange('dismiss', value, options);\n }\n _supportsDismissMethod(method) {\n return u.contains(this.dismissable, method);\n }\n _executeCloseChange(verb, value, options) {\n options = { ...options, verb, value, layer: this };\n return new up.Change.CloseLayer(options).execute();\n }\n getFirstSwappableElement() {\n return this.getContentElement().children[0];\n }\n toString() {\n return `${this.mode} overlay`;\n }\n};\n\n\n/***/ }),\n/* 51 */\n/***/ (() => {\n\nup.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {\n createElements() {\n if (!this.origin) {\n up.fail('Missing { origin } option');\n }\n this._tether = new up.Tether({\n anchor: this.origin,\n align: this.align,\n position: this.position\n });\n this.createElement(this._tether.parent);\n this.createContentElement(this.element);\n }\n onContentSet() {\n this._tether.start(this.element);\n }\n onElementsRemoved() {\n this._tether.stop();\n }\n sync() {\n if (this.isOpen()) {\n if (this.isDetached() || this._tether.isDetached()) {\n this.dismiss(':detached', {\n animation: false,\n preventable: false\n });\n }\n else {\n this._tether.sync();\n }\n }\n }\n};\n\n\n/***/ }),\n/* 52 */\n/***/ (() => {\n\nup.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overlay {\n static getParentElement() {\n return document.body;\n }\n createElements() {\n up.viewport.bodyShifter.raiseStack();\n this.createElement(this.constructor.getParentElement());\n if (this.backdrop) {\n this.createBackdropElement(this.element);\n }\n this.createViewportElement(this.element);\n this.createBoxElement(this.viewportElement);\n this.createContentElement(this.boxElement);\n }\n onElementsRemoved() {\n up.viewport.bodyShifter.lowerStack();\n }\n sync() {\n if (this.isDetached() && this.isOpen()) {\n this.constructor.getParentElement().appendChild(this.element);\n }\n }\n};\n\n\n/***/ }),\n/* 53 */\n/***/ (() => {\n\nvar _a;\nconst e = up.element;\nup.Layer.Root = (_a = class Root extends up.Layer {\n get element() {\n return e.root;\n }\n constructor(options) {\n super(options);\n this.setupHandlers();\n }\n getFirstSwappableElement() {\n return document.body;\n }\n static selector() {\n return 'html';\n }\n setupHandlers() {\n if (!this.element.upHandlersApplied) {\n this.element.upHandlersApplied = true;\n super.setupHandlers();\n }\n }\n sync() {\n this.setupHandlers();\n }\n accept() {\n this._cannotCloseRoot();\n }\n dismiss() {\n this._cannotCloseRoot();\n }\n _cannotCloseRoot() {\n up.fail('Cannot close the root layer');\n }\n toString() {\n return \"root layer\";\n }\n },\n _a.mode = 'root',\n _a);\n\n\n/***/ }),\n/* 54 */\n/***/ (() => {\n\nvar _a;\nup.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {\n },\n _a.mode = 'modal',\n _a);\n\n\n/***/ }),\n/* 55 */\n/***/ (() => {\n\nvar _a;\nup.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {\n },\n _a.mode = 'popup',\n _a);\n\n\n/***/ }),\n/* 56 */\n/***/ (() => {\n\nvar _a;\nup.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {\n },\n _a.mode = 'drawer',\n _a);\n\n\n/***/ }),\n/* 57 */\n/***/ (() => {\n\nvar _a;\nup.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {\n },\n _a.mode = 'cover',\n _a);\n\n\n/***/ }),\n/* 58 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.LayerLookup = class LayerLookup {\n constructor(stack, ...args) {\n this._stack = stack;\n const options = u.parseArgIntoOptions(args, 'layer');\n if (options.normalizeLayerOptions !== false) {\n up.layer.normalizeOptions(options);\n }\n this._values = u.parseTokens(options.layer);\n this._origin = options.origin;\n this._baseLayer = options.baseLayer || this._originLayer() || this._stack.current;\n if (u.isString(this._baseLayer)) {\n const recursiveOptions = { ...options, baseLayer: this._stack.current, normalizeLayerOptions: false };\n this._baseLayer = new this.constructor(this._stack, this._baseLayer, recursiveOptions).first();\n }\n }\n _originLayer() {\n if (this._origin) {\n return this._forElement(this._origin);\n }\n }\n first() {\n return this.all()[0];\n }\n all() {\n let results = u.flatMap(this._values, value => this._resolveValue(value));\n results = u.compact(results);\n results = u.uniq(results);\n return results;\n }\n _forElement(element) {\n element = e.get(element);\n return u.find(this._stack.reversed(), layer => layer.contains(element));\n }\n _forIndex(value) {\n return this._stack.at(value);\n }\n _resolveValue(value) {\n if (value instanceof up.Layer) {\n return value;\n }\n if (u.isNumber(value)) {\n return this._forIndex(value);\n }\n if (/^\\d+$/.test(value)) {\n return this._forIndex(Number(value));\n }\n if (u.isElementish(value)) {\n return this._forElement(value);\n }\n switch (value) {\n case 'any':\n return [this._baseLayer, ...this._stack.reversed()];\n case 'current':\n return this._baseLayer;\n case 'closest':\n return this._stack.selfAndAncestorsOf(this._baseLayer);\n case 'parent':\n return this._baseLayer.parent;\n case 'ancestor':\n case 'ancestors':\n return this._baseLayer.ancestors;\n case 'child':\n return this._baseLayer.child;\n case 'descendant':\n case 'descendants':\n return this._baseLayer.descendants;\n case 'subtree':\n return this._baseLayer.subtree;\n case 'new':\n return 'new';\n case 'root':\n return this._stack.root;\n case 'overlay':\n case 'overlays':\n return u.reverse(this._stack.overlays);\n case 'front':\n return this._stack.front;\n case 'origin':\n return this._originLayer();\n default:\n return up.fail(\"Unknown { layer } option: %o\", value);\n }\n }\n};\n\n\n/***/ }),\n/* 59 */\n/***/ (() => {\n\nconst u = up.util;\nup.LayerStack = class LayerStack {\n constructor() {\n this._currentOverrides = [];\n this.layers = [this._buildRoot()];\n }\n _buildRoot() {\n return up.layer.build({ mode: 'root', stack: this });\n }\n remove(layer) {\n u.remove(this.layers, layer);\n }\n peel(layer, options) {\n const descendants = u.reverse(layer.descendants);\n const dismissOptions = { ...options, preventable: false };\n for (let descendant of descendants) {\n descendant.dismiss(':peel', dismissOptions);\n }\n }\n reset() {\n this.peel(this.root, { animation: false });\n this._currentOverrides = [];\n this.root.reset();\n }\n isOpen(layer) {\n return u.contains(this.layers, layer);\n }\n isClosed(layer) {\n return !this.isOpen(layer);\n }\n parentOf(layer) {\n return this.layers[layer.index - 1];\n }\n childOf(layer) {\n return this.layers[layer.index + 1];\n }\n ancestorsOf(layer) {\n return u.reverse(this.layers.slice(0, layer.index));\n }\n selfAndAncestorsOf(layer) {\n return [layer, ...layer.ancestors];\n }\n descendantsOf(layer) {\n return this.layers.slice(layer.index + 1);\n }\n isRoot(layer) {\n return this.root === layer;\n }\n isOverlay(layer) {\n return this.root !== layer;\n }\n isCurrent(layer) {\n return this.current === layer;\n }\n isFront(layer) {\n return this.front === layer;\n }\n get(...args) {\n return this.getAll(...args)[0];\n }\n getAll(...args) {\n return new up.LayerLookup(this, ...args).all();\n }\n sync() {\n for (let layer of this.layers) {\n layer.sync();\n }\n }\n asCurrent(layer, fn) {\n try {\n this._currentOverrides.push(layer);\n return fn();\n }\n finally {\n this._currentOverrides.pop();\n }\n }\n reversed() {\n return u.reverse(this.layers);\n }\n dismissOverlays(value = null, options = {}) {\n options.dismissable = false;\n for (let overlay of u.reverse(this.overlays)) {\n overlay.dismiss(value, options);\n }\n }\n at(index) {\n return this.layers[index];\n }\n indexOf(layer) {\n return this.layers.indexOf(layer);\n }\n get count() {\n return this.layers.length;\n }\n get root() {\n return this.layers[0];\n }\n get overlays() {\n return this.root.descendants;\n }\n get current() {\n return u.last(this._currentOverrides) || this.front;\n }\n get front() {\n return u.last(this.layers);\n }\n};\n\n\n/***/ }),\n/* 60 */\n/***/ (() => {\n\nup.LinkFeedbackURLs = class LinkFeedbackURLs {\n constructor(link) {\n const normalize = up.feedback.normalizeURL;\n this._isSafe = up.link.isSafe(link);\n if (this._isSafe) {\n const href = link.getAttribute('href');\n if (href && (href !== '#')) {\n this.href = normalize(href);\n }\n const upHREF = link.getAttribute('up-href');\n if (upHREF) {\n this._upHREF = normalize(upHREF);\n }\n const alias = link.getAttribute('up-alias');\n if (alias) {\n this._aliasPattern = new up.URLPattern(alias, normalize);\n }\n }\n }\n isCurrent(normalizedLocation) {\n return this._isSafe && !!(this.href === normalizedLocation ||\n this._upHREF === normalizedLocation ||\n this._aliasPattern?.test?.(normalizedLocation, false));\n }\n};\n\n\n/***/ }),\n/* 61 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.LinkPreloader = class LinkPreloader {\n watchLink(link) {\n if (!up.link.preloadIssue(link)) {\n this._on(link, 'mouseenter', (event) => this._considerPreload(event, true));\n this._on(link, 'mousedown touchstart', (event) => this._considerPreload(event));\n this._on(link, 'mouseleave', (event) => this._stopPreload(event));\n }\n }\n _on(link, eventTypes, callback) {\n up.on(link, eventTypes, { passive: true }, callback);\n }\n _considerPreload(event, applyDelay) {\n const link = event.target;\n if (link !== this._currentLink) {\n this.reset();\n this._currentLink = link;\n if (up.link.shouldFollowEvent(event, link)) {\n if (applyDelay) {\n this._preloadAfterDelay(event, link);\n }\n else {\n this._preloadNow(event, link);\n }\n }\n }\n }\n _stopPreload(event) {\n if (event.target === this._currentLink) {\n return this.reset();\n }\n }\n reset() {\n if (!this._currentLink) {\n return;\n }\n clearTimeout(this._timer);\n if (this._currentRequest?.background) {\n this._currentRequest.abort();\n }\n this._currentLink = undefined;\n this._currentRequest = undefined;\n }\n _preloadAfterDelay(event, link) {\n const delay = e.numberAttr(link, 'up-preload-delay') ?? up.link.config.preloadDelay;\n this._timer = u.timer(delay, () => this._preloadNow(event, link));\n }\n _preloadNow(event, link) {\n if (!link.isConnected) {\n this.reset();\n return;\n }\n const onQueued = request => { return this._currentRequest = request; };\n up.log.putsEvent(event);\n up.error.muteUncriticalRejection(up.link.preload(link, { onQueued }));\n }\n};\n\n\n/***/ }),\n/* 62 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.MotionController = class MotionController {\n constructor(name) {\n this._activeClass = `up-${name}`;\n this._selector = `.${this._activeClass}`;\n this.finishEvent = `up:${name}:finish`;\n this.finishCount = 0;\n this._clusterCount = 0;\n }\n startFunction(cluster, startMotion, memory = {}) {\n cluster = e.list(cluster);\n const mutedAnimator = () => up.error.muteUncriticalRejection(startMotion());\n memory.trackMotion = memory.trackMotion ?? up.motion.isEnabled();\n if (memory.trackMotion === false) {\n return mutedAnimator();\n }\n else {\n memory.trackMotion = false;\n this.finish(cluster);\n this._markCluster(cluster);\n let promise = this._whileForwardingFinishEvent(cluster, mutedAnimator);\n promise = promise.then(() => this._unmarkCluster(cluster));\n return promise;\n }\n }\n finish(elements) {\n this.finishCount++;\n if ((this._clusterCount === 0) || !up.motion.isEnabled()) {\n return;\n }\n elements = this._expandFinishRequest(elements);\n for (let element of elements) {\n this._finishOneElement(element);\n }\n return up.migrate.formerlyAsync?.('up.motion.finish()');\n }\n _expandFinishRequest(elements) {\n if (elements) {\n return u.flatMap(elements, el => e.list(el.closest(this._selector), el.querySelectorAll(this._selector)));\n }\n else {\n return document.querySelectorAll(this._selector);\n }\n }\n isActive(element) {\n return element.classList.contains(this._activeClass);\n }\n _finishOneElement(element) {\n this._emitFinishEvent(element);\n }\n _emitFinishEvent(element, eventAttrs = {}) {\n eventAttrs = { target: element, log: false, ...eventAttrs };\n return up.emit(this.finishEvent, eventAttrs);\n }\n _markCluster(cluster) {\n this._clusterCount++;\n this._toggleActive(cluster, true);\n }\n _unmarkCluster(cluster) {\n this._clusterCount--;\n this._toggleActive(cluster, false);\n }\n _toggleActive(cluster, isActive) {\n for (let element of cluster) {\n element.classList.toggle(this._activeClass, isActive);\n }\n }\n _whileForwardingFinishEvent(cluster, fn) {\n if (cluster.length < 2) {\n return fn();\n }\n const doForward = (event) => {\n if (!event.forwarded) {\n for (let element of cluster) {\n if (element !== event.target && this.isActive(element)) {\n this._emitFinishEvent(element, { forwarded: true });\n }\n }\n }\n };\n const unbindFinish = up.on(cluster, this.finishEvent, doForward);\n return fn().then(unbindFinish);\n }\n async reset() {\n await this.finish();\n this.finishCount = 0;\n this._clusterCount = 0;\n }\n};\n\n\n/***/ }),\n/* 63 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.NonceableCallback = class NonceableCallback {\n constructor(script, nonce) {\n this.script = script;\n this.nonce = nonce;\n }\n static fromString(string) {\n let match = string.match(/^(nonce-([^\\s]+)\\s)?(.*)$/);\n return new this(match[3], match[2]);\n }\n toFunction(...argNames) {\n if (this.nonce) {\n let callbackThis = this;\n return function (...args) {\n return callbackThis._runAsNoncedFunction(this, argNames, args);\n };\n }\n else {\n return new Function(...argNames, this.script);\n }\n }\n toString() {\n return `nonce-${this.nonce} ${this.script}`;\n }\n _runAsNoncedFunction(thisArg, argNames, args) {\n let wrappedScript = `\n try {\n up.noncedEval.value = (function(${argNames.join()}) {\n ${this.script}\n }).apply(up.noncedEval.thisArg, up.noncedEval.args)\n } catch (error) {\n up.noncedEval.error = error\n }\n `;\n let script;\n try {\n up.noncedEval = { args, thisArg: thisArg };\n script = up.element.affix(document.body, 'script', { nonce: this.nonce, text: wrappedScript });\n if (up.noncedEval.error) {\n throw up.noncedEval.error;\n }\n else {\n return up.noncedEval.value;\n }\n }\n finally {\n up.noncedEval = undefined;\n if (script) {\n script.remove();\n }\n }\n }\n _allowedBy(allowedNonces) {\n return this.nonce && u.contains(allowedNonces, this.nonce);\n }\n static adoptNonces(element, allowedNonces) {\n if (!allowedNonces?.length) {\n return;\n }\n const getPageNonce = u.memoize(up.protocol.cspNonce);\n u.each(up.script.config.nonceableAttributes, (attribute) => {\n let matches = e.subtree(element, `[${attribute}^=\"nonce-\"]`);\n u.each(matches, (match) => {\n let attributeValue = match.getAttribute(attribute);\n let callback = this.fromString(attributeValue);\n let warn = (message, ...args) => up.log.warn('up.render()', `Cannot use callback [${attribute}=\"${attributeValue}\"]: ${message}`, ...args);\n if (!callback._allowedBy(allowedNonces)) {\n return warn(\"Callback's CSP nonce (%o) does not match response header (%o)\", callback.nonce, allowedNonces);\n }\n let pageNonce = getPageNonce();\n if (!pageNonce) {\n return warn(\"Current page's CSP nonce is unknown\");\n }\n callback.nonce = pageNonce;\n match.setAttribute(attribute, callback.toString());\n });\n });\n }\n};\n\n\n/***/ }),\n/* 64 */\n/***/ (() => {\n\nconst e = up.element;\nconst u = up.util;\nup.OverlayFocus = class OverlayFocus {\n constructor(layer) {\n this._layer = layer;\n this._focusElement = this._layer.getFocusElement();\n }\n moveToFront() {\n if (this._enabled) {\n return;\n }\n this._enabled = true;\n this._untrapFocus = up.on('focusin', event => this._onFocus(event));\n this._unsetAttrs = e.setTemporaryAttrs(this._focusElement, {\n 'tabindex': '0',\n 'role': 'dialog',\n 'aria-modal': 'true'\n });\n this._focusTrapBefore = e.affix(this._focusElement, 'beforebegin', 'up-focus-trap[tabindex=0]');\n this._focusTrapAfter = e.affix(this._focusElement, 'afterend', 'up-focus-trap[tabindex=0]');\n }\n moveToBack() {\n this.teardown();\n }\n teardown() {\n if (!this._enabled) {\n return;\n }\n this._enabled = false;\n this._untrapFocus();\n this._unsetAttrs();\n this._focusTrapBefore.remove();\n this._focusTrapAfter.remove();\n }\n _onFocus(event) {\n const { target } = event;\n if (this._processingFocusEvent || up.layer.isWithinForeignOverlay(target)) {\n return;\n }\n this._processingFocusEvent = true;\n if (target === this._focusTrapBefore) {\n this._focusEnd();\n }\n else if ((target === this._focusTrapAfter) || !this._layer.contains(target)) {\n this._focusStart();\n }\n this._processingFocusEvent = false;\n }\n _focusStart(focusOptions) {\n up.focus(this._focusElement, focusOptions);\n }\n _focusEnd() {\n this._focusLastDescendant(this._layer.getBoxElement()) || this._focusStart();\n }\n _focusLastDescendant(element) {\n for (let child of u.reverse(element.children)) {\n if (up.viewport.tryFocus(child) || this._focusLastDescendant(child)) {\n return true;\n }\n }\n }\n};\n\n\n/***/ }),\n/* 65 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.Params = class Params {\n constructor(raw) {\n this.clear();\n this.addAll(raw);\n }\n clear() {\n this.entries = [];\n }\n [u.copy.key]() {\n return new up.Params(this);\n }\n toObject() {\n const obj = {};\n for (let entry of this.entries) {\n const { name, value } = entry;\n if (!u.isBasicObjectProperty(name)) {\n if (this._isArrayKey(name)) {\n obj[name] ||= [];\n obj[name].push(value);\n }\n else {\n obj[name] = value;\n }\n }\n }\n return obj;\n }\n toArray() {\n return this.entries;\n }\n toFormData() {\n const formData = new FormData();\n for (let entry of this.entries) {\n formData.append(entry.name, entry.value);\n }\n if (!formData.entries) {\n formData.originalArray = this.entries;\n }\n return formData;\n }\n toQuery() {\n let parts = u.map(this.entries, this._arrayEntryToQuery.bind(this));\n parts = u.compact(parts);\n return parts.join('&');\n }\n _arrayEntryToQuery(entry) {\n const { value } = entry;\n if (this._isBinaryValue(value)) {\n return;\n }\n let query = encodeURIComponent(entry.name);\n if (u.isGiven(value)) {\n query += \"=\";\n query += encodeURIComponent(value);\n }\n return query;\n }\n _isBinaryValue(value) {\n return value instanceof Blob;\n }\n hasBinaryValues() {\n const values = u.map(this.entries, 'value');\n return u.some(values, this._isBinaryValue);\n }\n toURL(base) {\n let parts = [base, this.toQuery()];\n parts = u.filter(parts, u.isPresent);\n const separator = u.contains(base, '?') ? '&' : '?';\n return parts.join(separator);\n }\n add(name, value) {\n this.entries.push({ name, value });\n }\n addAll(raw) {\n if (u.isMissing(raw)) {\n }\n else if (raw instanceof this.constructor) {\n this.entries.push(...raw.entries);\n }\n else if (u.isArray(raw)) {\n this.entries.push(...raw);\n }\n else if (u.isString(raw)) {\n this._addAllFromQuery(raw);\n }\n else if (u.isFormData(raw)) {\n this._addAllFromFormData(raw);\n }\n else if (u.isObject(raw)) {\n this._addAllFromObject(raw);\n }\n else {\n up.fail(\"Unsupport params type: %o\", raw);\n }\n }\n _addAllFromObject(object) {\n for (let key in object) {\n const value = object[key];\n const valueElements = u.isArray(value) ? value : [value];\n for (let valueElement of valueElements) {\n this.add(key, valueElement);\n }\n }\n }\n _addAllFromQuery(query) {\n for (let part of query.split('&')) {\n if (part) {\n let [name, value] = part.split('=');\n name = decodeURIComponent(name);\n if (u.isGiven(value)) {\n value = decodeURIComponent(value);\n }\n else {\n value = null;\n }\n this.add(name, value);\n }\n }\n }\n _addAllFromFormData(formData) {\n for (let value of formData.entries()) {\n this.add(...value);\n }\n }\n set(name, value) {\n this.delete(name);\n this.add(name, value);\n }\n delete(name) {\n this.entries = u.reject(this.entries, this._matchEntryFn(name));\n }\n _matchEntryFn(name) {\n return entry => entry.name === name;\n }\n get(name) {\n if (this._isArrayKey(name)) {\n return this.getAll(name);\n }\n else {\n return this.getFirst(name);\n }\n }\n getFirst(name) {\n const entry = u.find(this.entries, this._matchEntryFn(name));\n return entry?.value;\n }\n getAll(name) {\n if (this._isArrayKey(name)) {\n return this.getAll(name);\n }\n else {\n const entries = u.map(this.entries, this._matchEntryFn(name));\n return u.map(entries, 'value');\n }\n }\n _isArrayKey(key) {\n return key.endsWith('[]');\n }\n [u.isBlank.key]() {\n return this.entries.length === 0;\n }\n static fromForm(form) {\n return this.fromContainer(form);\n }\n static fromContainer(container) {\n let fields = up.form.fields(container);\n return this.fromFields(fields);\n }\n static fromFields(fields) {\n const params = new (this)();\n for (let field of u.wrapList(fields)) {\n params.addField(field);\n }\n return params;\n }\n addField(field) {\n field = e.get(field);\n let name = field.name;\n if (name && !field.disabled) {\n const { tagName } = field;\n const { type } = field;\n if (tagName === 'SELECT') {\n for (let option of field.querySelectorAll('option')) {\n if (option.selected) {\n this.add(name, option.value);\n }\n }\n }\n else if ((type === 'checkbox') || (type === 'radio')) {\n if (field.checked) {\n this.add(name, field.value);\n }\n }\n else if (type === 'file') {\n for (let file of field.files) {\n this.add(name, file);\n }\n }\n else {\n return this.add(name, field.value);\n }\n }\n }\n [u.isEqual.key](other) {\n return (this.constructor === other.constructor) && u.isEqual(this.entries, other.entries);\n }\n static fromURL(url) {\n const params = new (this)();\n const urlParts = u.parseURL(url);\n let query = urlParts.search;\n if (query) {\n query = query.replace(/^\\?/, '');\n params.addAll(query);\n }\n return params;\n }\n static stripURL(url) {\n return u.normalizeURL(url, { search: false });\n }\n static merge(...objects) {\n return objects.reduce(function (allParams, params) {\n allParams.addAll(params);\n return allParams;\n }, new up.Params());\n }\n};\n\n\n/***/ }),\n/* 66 */\n/***/ (() => {\n\nconst e = up.element;\nconst TRANSITION_DELAY = 300;\nup.ProgressBar = class ProgressBar {\n constructor() {\n this._step = 0;\n this._element = e.affix(document.body, 'up-progress-bar');\n this._element.style.transition = `width ${TRANSITION_DELAY}ms ease-out`;\n this._moveTo(0);\n up.element.paint(this._element);\n this._width = 31;\n this._nextStep();\n }\n _nextStep() {\n let diff;\n if (this._width < 80) {\n if (Math.random() < 0.15) {\n diff = 7 + (5 * Math.random());\n }\n else {\n diff = 1.5 + (0.5 * Math.random());\n }\n }\n else {\n diff = 0.13 * (100 - this._width) * Math.random();\n }\n this._moveTo(this._width + diff);\n this._step++;\n const nextStepDelay = TRANSITION_DELAY + (this._step * 40);\n this.timeout = setTimeout(this._nextStep.bind(this), nextStepDelay);\n }\n _moveTo(width) {\n this._width = width;\n this._element.style.width = `${width}vw`;\n }\n destroy() {\n clearTimeout(this.timeout);\n this._element.remove();\n }\n conclude() {\n clearTimeout(this.timeout);\n this._moveTo(100);\n setTimeout(this.destroy.bind(this), TRANSITION_DELAY);\n }\n};\n\n\n/***/ }),\n/* 67 */\n/***/ (() => {\n\nconst u = up.util;\nup.RenderOptions = (function () {\n const GLOBAL_DEFAULTS = {\n useHungry: true,\n useKeep: true,\n saveScroll: true,\n saveFocus: true,\n focus: 'keep',\n abort: 'target',\n failOptions: true,\n };\n const PRELOAD_OVERRIDES = {\n abort: false,\n confirm: false,\n feedback: false,\n cache: true,\n background: true,\n };\n const PREFLIGHT_KEYS = [\n 'url',\n 'method',\n 'origin',\n 'headers',\n 'params',\n 'cache',\n 'fallback',\n 'abort',\n 'abortable',\n 'confirm',\n 'feedback',\n 'origin',\n 'baseLayer',\n 'fail',\n 'onError',\n ];\n const SHARED_KEYS = PREFLIGHT_KEYS.concat([\n 'keep',\n 'hungry',\n 'history',\n 'source',\n 'saveScroll',\n 'navigate',\n ]);\n const CONTENT_KEYS = [\n 'url',\n 'response',\n 'content',\n 'fragment',\n 'document',\n ];\n const LATE_KEYS = [\n 'history',\n 'focus',\n 'scroll',\n ];\n function navigateDefaults(options) {\n if (options.navigate) {\n return up.fragment.config.navigateOptions;\n }\n }\n function preloadOverrides(options) {\n if (options.preload) {\n return PRELOAD_OVERRIDES;\n }\n }\n function preprocess(options) {\n up.migrate.preprocessRenderOptions?.(options);\n const defaults = u.merge(GLOBAL_DEFAULTS, navigateDefaults(options));\n return u.merge(u.omit(defaults, LATE_KEYS), { defaults }, { inputDevice: up.event.inputDevice }, options, preloadOverrides(options));\n }\n function finalize(preprocessedOptions, lateDefaults) {\n return u.merge(preprocessedOptions.defaults, lateDefaults, preprocessedOptions);\n }\n function assertContentGiven(options) {\n if (!u.some(CONTENT_KEYS, contentKey => u.isGiven(options[contentKey]))) {\n if (options.defaultToEmptyContent) {\n options.content = '';\n }\n else {\n up.fail('up.render() needs either { ' + CONTENT_KEYS.join(', ') + ' } option');\n }\n }\n }\n function failOverrides(options) {\n const overrides = {};\n for (let key in options) {\n const value = options[key];\n let unprefixed = up.fragment.successKey(key);\n if (unprefixed) {\n overrides[unprefixed] = value;\n }\n }\n return overrides;\n }\n function deriveFailOptions(preprocessedOptions) {\n if (preprocessedOptions.failOptions) {\n return {\n ...preprocessedOptions.defaults,\n ...u.pick(preprocessedOptions, SHARED_KEYS),\n ...failOverrides(preprocessedOptions),\n ...{ failPrefixForced: true }\n };\n }\n else {\n return {\n ...preprocessedOptions,\n ...failOverrides(preprocessedOptions),\n };\n }\n }\n return {\n preprocess,\n finalize,\n assertContentGiven,\n deriveFailOptions,\n };\n})();\n\n\n/***/ }),\n/* 68 */\n/***/ (() => {\n\nup.RenderResult = class RenderResult extends up.Record {\n keys() {\n return [\n 'fragments',\n 'layer',\n 'target',\n 'options',\n 'finished',\n ];\n }\n defaults() {\n return {\n fragments: [],\n };\n }\n get none() {\n return !this.fragments.length;\n }\n get fragment() {\n return this.fragments[0];\n }\n static both(main, extension, mergeFinished = true) {\n if (!extension)\n return main;\n return new this({\n target: main.target,\n layer: main.layer,\n options: main.options,\n fragments: main.fragments.concat(extension.fragments),\n finished: (mergeFinished && this.mergeFinished(main, extension))\n });\n }\n static async mergeFinished(main, extension) {\n return this.both(await main.finished, await extension.finished, false);\n }\n static buildNone() {\n return new this({\n target: ':none',\n finished: Promise.resolve(),\n });\n }\n};\n\n\n/***/ }),\n/* 69 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nup.Request = (_a = class Request extends up.Record {\n keys() {\n return [\n 'method',\n 'url',\n 'hash',\n 'params',\n 'target',\n 'failTarget',\n 'headers',\n 'timeout',\n 'background',\n 'cache',\n 'expireCache',\n 'evictCache',\n 'layer',\n 'mode',\n 'context',\n 'failLayer',\n 'failMode',\n 'failContext',\n 'origin',\n 'fragments',\n 'builtAt',\n 'wrapMethod',\n 'contentType',\n 'payload',\n 'onQueued',\n 'onLoading',\n 'fail',\n 'abortable',\n 'badResponseTime',\n ];\n }\n defaults() {\n return {\n state: 'new',\n abortable: true,\n headers: {},\n timeout: up.network.config.timeout,\n builtAt: new Date(),\n };\n }\n constructor(options) {\n super(options);\n this.params = new up.Params(this.params);\n if (this.wrapMethod == null) {\n this.wrapMethod = up.network.config.wrapMethod;\n }\n this._normalize();\n if ((this.target || this.layer || this.origin) && !options.basic) {\n const layerLookupOptions = { origin: this.origin };\n this.layer = up.layer.get(this.layer, layerLookupOptions);\n this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);\n this.context ||= this.layer.context || {};\n this.failContext ||= this.failLayer?.context || {};\n this.mode ||= this.layer.mode;\n this.failMode ||= this.failLayer?.mode;\n }\n this.deferred = u.newDeferred();\n this.badResponseTime ??= u.evalOption(up.network.config.badResponseTime, this);\n this._addAutoHeaders();\n }\n get xhr() {\n return this._xhr ??= new XMLHttpRequest();\n }\n get fragments() {\n if (this._fragments) {\n return this._fragments;\n }\n else if (this.target) {\n let steps = up.fragment.parseTargetSteps(this.target);\n let selectors = u.map(steps, 'selector');\n let lookupOpts = { origin: this.origin, layer: this.layer };\n return u.compact(u.map(selectors, (selector) => up.fragment.get(selector, lookupOpts)));\n }\n }\n set fragments(value) {\n this._fragments = value;\n }\n get fragment() {\n return this.fragments?.[0];\n }\n _normalize() {\n this.method = u.normalizeMethod(this.method);\n this._extractHashFromURL();\n this._transferParamsToURL();\n this.url = u.normalizeURL(this.url);\n }\n _evictExpensiveAttrs() {\n u.task(() => {\n this.layer = undefined;\n this.failLayer = undefined;\n this.origin = undefined;\n this.fragments = undefined;\n });\n }\n _extractHashFromURL() {\n let match = this.url?.match(/^([^#]*)(#.+)$/);\n if (match) {\n this.url = match[1];\n return this.hash = match[2];\n }\n }\n _transferParamsToURL() {\n if (!this.url || this.allowsPayload() || u.isBlank(this.params)) {\n return;\n }\n this.url = this.params.toURL(this.url);\n this.params.clear();\n }\n isSafe() {\n return up.network.isSafeMethod(this.method);\n }\n allowsPayload() {\n return u.methodAllowsPayload(this.method);\n }\n will302RedirectWithGET() {\n return this.isSafe() || (this.method === 'POST');\n }\n willCache() {\n return u.evalAutoOption(this.cache, up.network.config.autoCache, this);\n }\n runQueuedCallbacks() {\n u.always(this, () => this._evictExpensiveAttrs());\n this.onQueued?.(this);\n }\n load() {\n if (this.state !== 'new')\n return;\n if (this._emitLoad()) {\n this.state = 'loading';\n this._normalize();\n this.onLoading?.();\n this.expired = false;\n new up.Request.XHRRenderer(this).buildAndSend({\n onload: () => this._onXHRLoad(),\n onerror: () => this._onXHRError(),\n ontimeout: () => this._onXHRTimeout(),\n onabort: () => this._onXHRAbort()\n });\n return true;\n }\n else {\n this.abort({ reason: 'Prevented by event listener' });\n }\n }\n _emitLoad() {\n let event = this.emit('up:request:load', { log: ['Loading %s', this.description] });\n return !event.defaultPrevented;\n }\n loadPage() {\n up.network.abort();\n new up.Request.FormRenderer(this).buildAndSubmit();\n }\n _onXHRLoad() {\n const response = this._extractResponseFromXHR();\n const log = 'Loaded ' + response.description;\n this.emit('up:request:loaded', { request: response.request, response, log });\n this.respondWith(response);\n }\n _onXHRError() {\n this._setOfflineState('Network error');\n }\n _onXHRTimeout() {\n this._setOfflineState('Timeout');\n }\n _onXHRAbort() {\n this._setAbortedState();\n }\n abort({ reason } = {}) {\n if (this._setAbortedState(reason) && this._xhr) {\n this._xhr.abort();\n }\n }\n _setAbortedState(reason) {\n if (this._isSettled())\n return;\n let message = 'Aborted request to ' + this.description + (reason ? ': ' + reason : '');\n this.state = 'aborted';\n this.deferred.reject(new up.Aborted(message));\n this.emit('up:request:aborted', { log: message });\n return true;\n }\n _setOfflineState(reason) {\n if (this._isSettled())\n return;\n let message = 'Cannot load request to ' + this.description + (reason ? ': ' + reason : '');\n this.state = 'offline';\n this.emit('up:request:offline', { log: message });\n this.deferred.reject(new up.Offline(message));\n }\n respondWith(response) {\n this.response = response;\n if (this._isSettled())\n return;\n this.state = 'loaded';\n if (response.ok) {\n this.deferred.resolve(response);\n }\n else {\n this.deferred.reject(response);\n }\n }\n _isSettled() {\n return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');\n }\n csrfHeader() {\n return up.protocol.csrfHeader();\n }\n csrfParam() {\n return up.protocol.csrfParam();\n }\n csrfToken() {\n if (!this.isSafe() && !this.isCrossOrigin()) {\n return up.protocol.csrfToken();\n }\n }\n isCrossOrigin() {\n return u.isCrossOrigin(this.url);\n }\n _extractResponseFromXHR() {\n const responseAttrs = {\n method: this.method,\n url: this.url,\n request: this,\n xhr: this.xhr,\n text: this.xhr.responseText,\n status: this.xhr.status,\n title: up.protocol.titleFromXHR(this.xhr),\n target: up.protocol.targetFromXHR(this.xhr),\n acceptLayer: up.protocol.acceptLayerFromXHR(this.xhr),\n dismissLayer: up.protocol.dismissLayerFromXHR(this.xhr),\n eventPlans: up.protocol.eventPlansFromXHR(this.xhr),\n context: up.protocol.contextFromXHR(this.xhr),\n expireCache: up.protocol.expireCacheFromXHR(this.xhr),\n evictCache: up.protocol.evictCacheFromXHR(this.xhr),\n fail: this.fail,\n };\n let methodFromResponse = up.protocol.methodFromXHR(this.xhr);\n let urlFromResponse = up.protocol.locationFromXHR(this.xhr);\n if (urlFromResponse) {\n if (!u.matchURLs(this.url, urlFromResponse)) {\n methodFromResponse ||= 'GET';\n }\n responseAttrs.url = urlFromResponse;\n }\n if (methodFromResponse) {\n responseAttrs.method = methodFromResponse;\n }\n return new up.Response(responseAttrs);\n }\n _buildEventEmitter(args) {\n return up.EventEmitter.fromEmitArgs(args, {\n layer: this.layer,\n request: this,\n origin: this.origin\n });\n }\n emit(...args) {\n return this._buildEventEmitter(args).emit();\n }\n assertEmitted(...args) {\n this._buildEventEmitter(args).assertEmitted();\n }\n get description() {\n return this.method + ' ' + this.url;\n }\n isPartOfSubtree(subtreeElements) {\n if (!this.fragments || !subtreeElements) {\n return false;\n }\n subtreeElements = u.wrapList(subtreeElements);\n return u.some(this.fragments, function (fragment) {\n return u.some(subtreeElements, (subtreeElement) => subtreeElement.contains(fragment));\n });\n }\n get age() {\n return new Date() - this.builtAt;\n }\n header(name) {\n return this.headers[name];\n }\n _addAutoHeaders() {\n for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {\n this._addAutoHeader(up.protocol.headerize(key), this[key]);\n }\n let csrfHeader, csrfToken;\n if ((csrfHeader = this.csrfHeader()) && (csrfToken = this.csrfToken())) {\n this._addAutoHeader(csrfHeader, csrfToken);\n }\n this._addAutoHeader(up.protocol.headerize('version'), up.version);\n }\n _addAutoHeader(name, value) {\n if (u.isMissing(value)) {\n return;\n }\n if (u.isOptions(value) || u.isArray(value)) {\n value = u.safeStringifyJSON(value);\n }\n this.headers[name] = value;\n }\n static tester(condition, { except } = {}) {\n let testFn;\n if (u.isFunction(condition)) {\n testFn = condition;\n }\n else if (condition instanceof this) {\n testFn = (request) => condition === request;\n }\n else if (u.isString(condition)) {\n let pattern = new up.URLPattern(condition);\n testFn = (request) => pattern.test(request.url);\n }\n else {\n testFn = (_request) => condition;\n }\n if (except) {\n return (request) => !up.cache.willHaveSameResponse(request, except) && testFn(request);\n }\n else {\n return testFn;\n }\n }\n },\n (() => {\n u.delegate(_a.prototype, ['then', 'catch', 'finally'], function () { return this.deferred; });\n })(),\n _a);\n\n\n/***/ }),\n/* 70 */\n/***/ (() => {\n\nconst u = up.util;\nup.Request.Cache = class Cache {\n constructor() {\n this.reset();\n }\n reset() {\n this._varyInfo = {};\n this._map = new Map();\n }\n _cacheKey(request) {\n let influencingHeaders = this._getPreviousInfluencingHeaders(request);\n let varyPart = u.flatMap(influencingHeaders, (headerName) => [headerName, request.header(headerName)]);\n return [request.description, ...varyPart].join(':');\n }\n _getPreviousInfluencingHeaders(request) {\n return (this._varyInfo[request.description] ||= new Set());\n }\n get(request) {\n request = this._wrap(request);\n let cacheKey = this._cacheKey(request);\n let cachedRequest = this._map.get(cacheKey);\n if (cachedRequest) {\n if (this._isUsable(cachedRequest)) {\n return cachedRequest;\n }\n else {\n this._map.delete(cacheKey);\n }\n }\n }\n get _capacity() {\n return up.network.config.cacheSize;\n }\n _isUsable(request) {\n return request.age < up.network.config.cacheEvictAge;\n }\n async put(request) {\n request = this._wrap(request);\n this._makeRoom();\n let cacheKey = this._updateCacheKey(request);\n this._map.set(cacheKey, request);\n }\n _updateCacheKey(request) {\n let oldCacheKey = this._cacheKey(request);\n let { response } = request;\n if (response) {\n this._mergePreviousHeaderNames(request, response);\n let newCacheKey = this._cacheKey(request);\n this._renameMapKey(oldCacheKey, newCacheKey);\n return newCacheKey;\n }\n else {\n return oldCacheKey;\n }\n }\n _renameMapKey(oldKey, newKey) {\n if (oldKey !== newKey && this._map.has(oldKey)) {\n this._map.set(newKey, this._map.get(oldKey));\n this._map.delete(oldKey);\n }\n }\n _mergePreviousHeaderNames(request, response) {\n let headersInfluencingResponse = response.ownInfluncingHeaders;\n if (headersInfluencingResponse.length) {\n let previousInfluencingHeaders = this._getPreviousInfluencingHeaders(request);\n for (let headerName of headersInfluencingResponse) {\n previousInfluencingHeaders.add(headerName);\n }\n }\n }\n alias(existingCachedRequest, newRequest) {\n existingCachedRequest = this.get(existingCachedRequest);\n if (!existingCachedRequest)\n return;\n newRequest = this._wrap(newRequest);\n this.track(existingCachedRequest, newRequest, { force: true });\n this.put(newRequest);\n return newRequest;\n }\n async track(existingRequest, newRequest, options = {}) {\n newRequest.trackedRequest = existingRequest;\n newRequest.state = 'tracking';\n let value = await u.always(existingRequest);\n if (value instanceof up.Response) {\n if (options.force || this._isCacheCompatible(existingRequest, newRequest)) {\n newRequest.fromCache = true;\n value = u.variant(value, { request: newRequest });\n newRequest.respondWith(value);\n u.delegate(newRequest, ['expired', 'state'], () => existingRequest);\n }\n else {\n delete newRequest.trackedRequest;\n newRequest.state = 'new';\n options.onIncompatible?.(newRequest);\n }\n }\n else {\n newRequest.state = existingRequest.state;\n newRequest.deferred.reject(value);\n }\n }\n willHaveSameResponse(existingRequest, newRequest) {\n return existingRequest === newRequest || existingRequest === newRequest.trackedRequest;\n }\n _delete(request) {\n request = this._wrap(request);\n let cacheKey = this._cacheKey(request);\n this._map.delete(cacheKey);\n }\n evict(condition = true, testerOptions) {\n this._eachMatch(condition, testerOptions, (request) => this._delete(request));\n }\n expire(condition = true, testerOptions) {\n this._eachMatch(condition, testerOptions, (request) => request.expired = true);\n }\n _makeRoom() {\n while (this._map.size >= this._capacity) {\n let oldestKey = this._map.keys().next().value;\n this._map.delete(oldestKey);\n }\n }\n _eachMatch(condition = true, testerOptions, fn) {\n let tester = up.Request.tester(condition, testerOptions);\n let results = u.filter(this._map.values(), tester);\n u.each(results, fn);\n }\n _isCacheCompatible(request1, request2) {\n return this._cacheKey(request1) === this._cacheKey(request2);\n }\n _wrap(requestOrOptions) {\n return u.wrapValue(up.Request, requestOrOptions);\n }\n};\n\n\n/***/ }),\n/* 71 */\n/***/ (() => {\n\nconst u = up.util;\nup.Request.Queue = class Queue {\n constructor() {\n this.reset();\n }\n reset() {\n this._queuedRequests = [];\n this._currentRequests = [];\n this._emittedLate = false;\n }\n get allRequests() {\n return this._currentRequests.concat(this._queuedRequests);\n }\n asap(request) {\n request.runQueuedCallbacks();\n u.always(request, responseOrError => this._onRequestSettled(request, responseOrError));\n this._scheduleSlowTimer(request);\n this._queueRequest(request);\n u.microtask(() => this._poke());\n }\n promoteToForeground(request) {\n if (request.background) {\n request.background = false;\n this._scheduleSlowTimer(request);\n }\n }\n _scheduleSlowTimer(request) {\n let timeUntilLate = Math.max(request.badResponseTime - request.age, 0);\n u.timer(timeUntilLate, () => this._checkLate());\n }\n _getMaxConcurrency() {\n return u.evalOption(up.network.config.concurrency);\n }\n _hasConcurrencyLeft() {\n const maxConcurrency = this._getMaxConcurrency();\n return (maxConcurrency === -1) || (this._currentRequests.length < maxConcurrency);\n }\n isBusy() {\n return this._currentRequests.length > 0 || this._queuedRequests.length > 0;\n }\n _queueRequest(request) {\n this._queuedRequests.push(request);\n }\n _pluckNextRequest() {\n let request = u.find(this._queuedRequests, request => !request.background);\n request ||= this._queuedRequests[0];\n return u.remove(this._queuedRequests, request);\n }\n _sendRequestNow(request) {\n if (request.load()) {\n this._currentRequests.push(request);\n }\n }\n _onRequestSettled(request, responseOrError) {\n u.remove(this._currentRequests, request) || u.remove(this._queuedRequests, request);\n if ((responseOrError instanceof up.Response) && responseOrError.ok) {\n up.network.registerAliasForRedirect(request, responseOrError);\n }\n this._checkLate();\n u.microtask(() => this._poke());\n }\n _poke() {\n let request;\n if (this._hasConcurrencyLeft() && (request = this._pluckNextRequest())) {\n return this._sendRequestNow(request);\n }\n }\n abort(...args) {\n let options = u.extractOptions(args);\n let { except, reason, logOnce } = options;\n let conditions = args[0] ?? true;\n let tester = up.Request.tester(conditions, { except });\n for (let list of [this._currentRequests, this._queuedRequests]) {\n const abortableRequests = u.filter(list, tester);\n for (let abortableRequest of abortableRequests) {\n if (logOnce) {\n up.puts(...logOnce);\n logOnce = null;\n }\n abortableRequest.abort({ reason });\n u.remove(list, abortableRequest);\n }\n }\n }\n _checkLate() {\n const currentLate = this._isLate();\n if (this._emittedLate !== currentLate) {\n this._emittedLate = currentLate;\n if (currentLate) {\n up.emit('up:network:late', { log: 'Server is slow to respond' });\n }\n else {\n up.emit('up:network:recover', { log: 'Slow requests were loaded' });\n }\n }\n }\n _isLate() {\n const allForegroundRequests = u.reject(this.allRequests, 'background');\n const timerTolerance = 1;\n return u.some(allForegroundRequests, (request) => request.age >= (request.badResponseTime - timerTolerance));\n }\n};\n\n\n/***/ }),\n/* 72 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nconst HTML_FORM_METHODS = ['GET', 'POST'];\nup.Request.FormRenderer = class FormRenderer {\n constructor(request) {\n this._request = request;\n }\n buildAndSubmit() {\n this.params = u.copy(this._request.params);\n let action = this._request.url;\n let { method } = this._request;\n const paramsFromQuery = up.Params.fromURL(action);\n this.params.addAll(paramsFromQuery);\n action = up.Params.stripURL(action);\n if (!u.contains(HTML_FORM_METHODS, method)) {\n method = up.protocol.wrapMethod(method, this.params);\n }\n this._form = e.affix(document.body, 'form.up-request-loader', { method, action });\n let contentType = this._request.contentType;\n if (contentType) {\n this._form.setAttribute('enctype', contentType);\n }\n let csrfParam, csrfToken;\n if ((csrfParam = this._request.csrfParam()) && (csrfToken = this._request.csrfToken())) {\n this.params.add(csrfParam, csrfToken);\n }\n u.each(this.params.toArray(), this._addField.bind(this));\n up.browser.submitForm(this._form);\n }\n _addField(attrs) {\n e.affix(this._form, 'input[type=hidden]', attrs);\n }\n};\n\n\n/***/ }),\n/* 73 */\n/***/ (() => {\n\nvar _a;\nconst CONTENT_TYPE_URL_ENCODED = 'application/x-www-form-urlencoded';\nconst CONTENT_TYPE_FORM_DATA = 'multipart/form-data';\nconst u = up.util;\nup.Request.XHRRenderer = (_a = class XHRRenderer {\n constructor(request) {\n this._request = request;\n }\n buildAndSend(handlers) {\n const xhr = this._request.xhr;\n this._params = u.copy(this._request.params);\n if (this._request.timeout) {\n xhr.timeout = this._request.timeout;\n }\n xhr.open(this._getMethod(), this._request.url);\n let contentType = this._getContentType();\n if (contentType) {\n xhr.setRequestHeader('Content-Type', contentType);\n }\n for (let headerName in this._request.headers) {\n let headerValue = this._request.headers[headerName];\n xhr.setRequestHeader(headerName, headerValue);\n }\n Object.assign(xhr, handlers);\n xhr.send(this._getPayload());\n }\n _getMethod() {\n let method = this._request.method;\n if (this._request.wrapMethod && !this._request.will302RedirectWithGET()) {\n method = up.protocol.wrapMethod(method, this._params);\n }\n return method;\n }\n _getContentType() {\n this._finalizePayload();\n return this._contentType;\n }\n _getPayload() {\n this._finalizePayload();\n return this._payload;\n }\n _finalizePayload() {\n this._payload = this._request.payload;\n this._contentType = this._request.contentType;\n if (!this._payload && this._request.allowsPayload()) {\n if (!this._contentType) {\n this._contentType = this._params.hasBinaryValues() ? CONTENT_TYPE_FORM_DATA : CONTENT_TYPE_URL_ENCODED;\n }\n if (this._contentType === CONTENT_TYPE_FORM_DATA) {\n this._contentType = null;\n this._payload = this._params.toFormData();\n }\n else {\n this._payload = this._params.toQuery().replace(/%20/g, '+');\n }\n }\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _finalizePayload: true,\n _getMethod: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 74 */\n/***/ (() => {\n\nconst u = up.util;\nup.Response = class Response extends up.Record {\n keys() {\n return [\n 'method',\n 'url',\n 'text',\n 'status',\n 'request',\n 'xhr',\n 'target',\n 'title',\n 'acceptLayer',\n 'dismissLayer',\n 'eventPlans',\n 'context',\n 'expireCache',\n 'evictCache',\n 'headers',\n 'loadedAt',\n 'fail',\n ];\n }\n defaults() {\n return {\n headers: {},\n loadedAt: new Date()\n };\n }\n get ok() {\n return !u.evalOption(this.fail ?? up.network.config.fail, this);\n }\n get none() {\n return !this.text;\n }\n isCacheable() {\n return this.ok && !this.none;\n }\n header(name) {\n return this.headers[name] || this.xhr?.getResponseHeader(name);\n }\n get ownInfluncingHeaders() {\n let influencingHeaders = up.protocol.influencingHeadersFromResponse(this);\n return u.filter(influencingHeaders, (headerName) => this.request.header(headerName));\n }\n get contentType() {\n return this.header('Content-Type');\n }\n get cspNonces() {\n return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only'));\n }\n get lastModified() {\n let header = this.header('Last-Modified');\n if (header) {\n return new Date(header);\n }\n }\n get etag() {\n return this.header('ETag');\n }\n get json() {\n return this.parsedJSON ||= JSON.parse(this.text);\n }\n get age() {\n let now = new Date();\n return now - this.loadedAt;\n }\n get expired() {\n return this.age > up.network.config.cacheExpireAge ||\n this.request.expired;\n }\n get description() {\n return `HTTP ${this.status} response to ${this.request.description}`;\n }\n};\n\n\n/***/ }),\n/* 75 */\n/***/ (() => {\n\nvar _a;\nconst u = up.util;\nconst e = up.element;\nup.ResponseDoc = (_a = class ResponseDoc {\n constructor({ document, fragment, content, target, origin, cspNonces, match }) {\n if (document) {\n this._parseDocument(document);\n }\n else if (fragment) {\n this._parseFragment(fragment);\n }\n else {\n this._parseContent(content || '', target);\n }\n this._cspNonces = cspNonces;\n if (origin) {\n let originSelector = up.fragment.tryToTarget(origin);\n if (originSelector) {\n this._rediscoveredOrigin = this.select(originSelector);\n }\n }\n this._match = match;\n }\n _parseDocument(document) {\n document = this._parse(document, e.createBrokenDocumentFromHTML);\n this._isDocumentBroken = true;\n this._useParseResult(document);\n }\n _parseFragment(fragment) {\n fragment = this._parse(fragment, e.createFromHTML);\n this._useParseResult(fragment);\n }\n _parseContent(content, target) {\n if (!target)\n up.fail(\"must pass a { target } when passing { content }\");\n target = u.map(up.fragment.parseTargetSteps(target), 'selector').join();\n const matchingElement = e.createFromSelector(target);\n if (u.isString(content)) {\n matchingElement.innerHTML = content;\n }\n else {\n matchingElement.appendChild(content);\n }\n this._useParseResult(matchingElement);\n }\n _parse(value, parseFn) {\n if (u.isString(value)) {\n value = parseFn(value);\n }\n return value;\n }\n _useParseResult(node) {\n if (node instanceof Document) {\n this._document = node;\n }\n else {\n this._document = document.createElement('up-document');\n this._document.append(node);\n this._document.documentElement = node;\n }\n }\n rootSelector() {\n return up.fragment.toTarget(this._document.documentElement);\n }\n get title() {\n return this._fromHead(this._getTitleText);\n }\n _getHead() {\n let { head } = this._document;\n if (head && head.childNodes.length > 0) {\n return head;\n }\n }\n _fromHead(fn) {\n let head = this._getHead();\n return head && fn(head);\n }\n get metaTags() {\n return this._fromHead(up.history.findMetaTags);\n }\n get assets() {\n return this._fromHead(up.script.findAssets);\n }\n _getTitleText(head) {\n return head.querySelector('title')?.textContent;\n }\n select(selector) {\n let finder = new up.FragmentFinder({\n selector: selector,\n origin: this._rediscoveredOrigin,\n document: this._document,\n match: this._match,\n });\n return finder.find();\n }\n selectSteps(steps) {\n return steps.filter((step) => {\n return this._trySelectStep(step) || this._cannotMatchStep(step);\n });\n }\n commitSteps(steps) {\n return steps.filter((step) => this.commitElement(step.newElement));\n }\n _trySelectStep(step) {\n if (step.newElement) {\n return true;\n }\n let newElement = this.select(step.selector);\n if (!newElement) {\n return;\n }\n let { selectEvent } = step;\n if (selectEvent) {\n selectEvent.newFragment = newElement;\n selectEvent.renderOptions = step.originalRenderOptions;\n up.emit(step.oldElement, selectEvent, { callback: step.selectCallback });\n if (selectEvent.defaultPrevented) {\n return;\n }\n }\n step.newElement = newElement;\n return true;\n }\n _cannotMatchStep(step) {\n if (!step.maybe) {\n throw new up.CannotMatch();\n }\n }\n commitElement(element) {\n if (this._document.contains(element)) {\n if (!up.fragment.config.runScripts) {\n up.script.disableSubtree(element);\n }\n element.remove();\n return true;\n }\n }\n finalizeElement(element) {\n up.NonceableCallback.adoptNonces(element, this._cspNonces);\n if (this._isDocumentBroken) {\n let brokenElements = e.subtree(element, ':is(noscript,script,audio,video):not(.up-keeping, .up-keeping *)');\n u.each(brokenElements, e.fixParserDamage);\n }\n }\n },\n (() => {\n u.memoizeMethod(_a.prototype, {\n _getHead: true,\n });\n })(),\n _a);\n\n\n/***/ }),\n/* 76 */\n/***/ (() => {\n\nconst e = up.element;\nconst u = up.util;\nup.RevealMotion = class RevealMotion {\n constructor(element, options = {}) {\n this._element = element;\n this._viewport = e.get(options.viewport) || up.viewport.get(this._element);\n this._obstructionsLayer = up.layer.get(this._viewport);\n this._behavior = options.behavior ?? 'instant';\n const viewportConfig = up.viewport.config;\n this._snap = options.snap ?? options.revealSnap ?? viewportConfig.revealSnap;\n this._padding = options.padding ?? options.revealPadding ?? viewportConfig.revealPadding;\n this._top = options.top ?? options.revealTop ?? viewportConfig.revealTop;\n this._max = options.max ?? options.revealMax ?? viewportConfig.revealMax;\n this._topObstructionSelector = viewportConfig.selector('fixedTopSelectors');\n this._bottomObstructionSelector = viewportConfig.selector('fixedBottomSelectors');\n }\n start() {\n const viewportRect = this._getViewportRect(this._viewport);\n const elementRect = up.Rect.fromElement(this._element);\n if (this._max) {\n const maxPixels = u.evalOption(this._max, this._element);\n elementRect.height = Math.min(elementRect.height, maxPixels);\n }\n this._addPadding(elementRect);\n this._substractObstructions(viewportRect);\n if (viewportRect.height < 0) {\n up.fail('Viewport has no visible area');\n }\n const originalScrollTop = this._viewport.scrollTop;\n let newScrollTop = originalScrollTop;\n if (this._top || (elementRect.height > viewportRect.height)) {\n const diff = elementRect.top - viewportRect.top;\n newScrollTop += diff;\n }\n else if (elementRect.top < viewportRect.top) {\n newScrollTop -= (viewportRect.top - elementRect.top);\n }\n else if (elementRect.bottom > viewportRect.bottom) {\n newScrollTop += (elementRect.bottom - viewportRect.bottom);\n }\n else {\n }\n if (u.isNumber(this._snap) && (newScrollTop < this._snap) && (elementRect.top < (0.5 * viewportRect.height))) {\n newScrollTop = 0;\n }\n if (newScrollTop !== originalScrollTop) {\n this._viewport.scrollTo({ top: newScrollTop, behavior: this._behavior });\n }\n }\n _getViewportRect() {\n if (up.viewport.isRoot(this._viewport)) {\n return new up.Rect({\n left: 0,\n top: 0,\n width: up.viewport.rootWidth(),\n height: up.viewport.rootHeight()\n });\n }\n else {\n return up.Rect.fromElement(this._viewport);\n }\n }\n _addPadding(elementRect) {\n elementRect.top -= this._padding;\n elementRect.height += 2 * this._padding;\n }\n _selectObstructions(selector) {\n let elements = up.fragment.all(selector, { layer: this._obstructionsLayer });\n return u.filter(elements, e.isVisible);\n }\n _substractObstructions(viewportRect) {\n for (let obstruction of this._selectObstructions(this._topObstructionSelector)) {\n let obstructionRect = up.Rect.fromElement(obstruction);\n let diff = obstructionRect.bottom - viewportRect.top;\n if (diff > 0) {\n viewportRect.top += diff;\n viewportRect.height -= diff;\n }\n }\n for (let obstruction of this._selectObstructions(this._bottomObstructionSelector)) {\n let obstructionRect = up.Rect.fromElement(obstruction);\n let diff = viewportRect.bottom - obstructionRect.top;\n if (diff > 0) {\n viewportRect.height -= diff;\n }\n }\n }\n};\n\n\n/***/ }),\n/* 77 */\n/***/ (() => {\n\nconst u = up.util;\nconst CSS_HAS_SUFFIX_PATTERN = /:has\\(([^)]+)\\)$/;\nup.Selector = class Selector {\n constructor(selector, elementOrDocument, options = {}) {\n this._filters = [];\n if (!options.destroying) {\n this._filters.push(up.fragment.isNotDestroying);\n }\n let matchingInExternalDocument = elementOrDocument && !document.contains(elementOrDocument);\n let expandTargetLayer;\n if (matchingInExternalDocument || options.layer === 'any') {\n expandTargetLayer = up.layer.root;\n }\n else {\n options.layer ??= u.presence(elementOrDocument, u.isElement);\n this._layers = up.layer.getAll(options);\n if (!this._layers.length)\n throw new up.CannotMatch([\"Unknown layer: %o\", options.layer]);\n this._filters.push(match => u.some(this._layers, layer => layer.contains(match)));\n expandTargetLayer = this._layers[0];\n }\n let expandedTargets = up.fragment.expandTargets(selector, { ...options, layer: expandTargetLayer });\n this._selectors = expandedTargets.map((target) => {\n if (!up.browser.canHasSelector()) {\n target = target.replace(CSS_HAS_SUFFIX_PATTERN, (match, descendantSelector) => {\n this._filters.push(element => element.querySelector(descendantSelector));\n return '';\n });\n }\n return target || '*';\n });\n this._unionSelector = this._selectors.join() || 'match-none';\n }\n matches(element) {\n return element.matches(this._unionSelector) && this._passesFilter(element);\n }\n closest(element) {\n let parentElement;\n if (this.matches(element)) {\n return element;\n }\n else if (parentElement = element.parentElement) {\n return this.closest(parentElement);\n }\n }\n _passesFilter(element) {\n return u.every(this._filters, filter => filter(element));\n }\n descendants(root = document) {\n const results = u.flatMap(this._selectors, selector => root.querySelectorAll(selector));\n return u.filter(results, element => this._passesFilter(element));\n }\n subtree(root) {\n const results = [];\n if (!(root instanceof Document) && this.matches(root)) {\n results.push(root);\n }\n results.push(...this.descendants(root));\n return results;\n }\n};\n\n\n/***/ }),\n/* 78 */\n/***/ (() => {\n\nconst u = up.util;\nconst e = up.element;\nup.Tether = class Tether {\n constructor(options) {\n up.migrate.handleTetherOptions?.(options);\n this._anchor = options.anchor;\n this._align = options.align;\n this._position = options.position;\n this._alignAxis = (this._position === 'top') || (this._position === 'bottom') ? 'horizontal' : 'vertical';\n this._viewport = up.viewport.get(this._anchor);\n this.parent = this._viewport === e.root ? document.body : this._viewport;\n this._syncOnScroll = !this._viewport.contains(this._anchor.offsetParent);\n }\n start(element) {\n this._element = element;\n this._element.style.position = 'absolute';\n this._setOffset(0, 0);\n this.sync();\n this._changeEventSubscription('on');\n }\n stop() {\n this._changeEventSubscription('off');\n }\n _changeEventSubscription(fn) {\n let doScheduleSync = this._scheduleSync.bind(this);\n up[fn](window, 'resize', doScheduleSync);\n if (this._syncOnScroll) {\n up[fn](this._viewport, 'scroll', doScheduleSync);\n }\n }\n _scheduleSync() {\n clearTimeout(this.syncTimer);\n return this.syncTimer = u.task(this.sync.bind(this));\n }\n isDetached() {\n return !this.parent.isConnected || !this._anchor.isConnected;\n }\n sync() {\n const elementBox = this._element.getBoundingClientRect();\n const elementMargin = {\n top: e.styleNumber(this._element, 'marginTop'),\n right: e.styleNumber(this._element, 'marginRight'),\n bottom: e.styleNumber(this._element, 'marginBottom'),\n left: e.styleNumber(this._element, 'marginLeft')\n };\n const anchorBox = this._anchor.getBoundingClientRect();\n let left;\n let top;\n switch (this._alignAxis) {\n case 'horizontal': {\n switch (this._position) {\n case 'top':\n top = anchorBox.top - elementMargin.bottom - elementBox.height;\n break;\n case 'bottom':\n top = anchorBox.top + anchorBox.height + elementMargin.top;\n break;\n }\n switch (this._align) {\n case 'left':\n left = anchorBox.left + elementMargin.left;\n break;\n case 'center':\n left = anchorBox.left + (0.5 * (anchorBox.width - elementBox.width));\n break;\n case 'right':\n left = (anchorBox.left + anchorBox.width) - elementBox.width - elementMargin.right;\n break;\n }\n break;\n }\n case 'vertical': {\n switch (this._align) {\n case 'top':\n top = anchorBox.top + elementMargin.top;\n break;\n case 'center':\n top = anchorBox.top + (0.5 * (anchorBox.height - elementBox.height));\n break;\n case 'bottom':\n top = (anchorBox.top + anchorBox.height) - elementBox.height - elementMargin.bottom;\n break;\n }\n switch (this._position) {\n case 'left':\n left = anchorBox.left - elementMargin.right - elementBox.width;\n break;\n case 'right':\n left = anchorBox.left + anchorBox.width + elementMargin.left;\n break;\n }\n break;\n }\n }\n if (u.isDefined(left) || u.isDefined(top)) {\n this._moveTo(left, top);\n }\n else {\n up.fail('Invalid tether constraints: %o', this._describeConstraints());\n }\n }\n _describeConstraints() {\n return { position: this._position, align: this._align };\n }\n _moveTo(targetLeft, targetTop) {\n const elementBox = this._element.getBoundingClientRect();\n this._setOffset((targetLeft - elementBox.left) + this.offsetLeft, (targetTop - elementBox.top) + this.offsetTop);\n }\n _setOffset(left, top) {\n this.offsetLeft = left;\n this.offsetTop = top;\n e.setStyle(this._element, { left, top });\n }\n};\n\n\n/***/ }),\n/* 79 */\n/***/ (() => {\n\nconst u = up.util;\nup.URLPattern = class URLPattern {\n constructor(fullPattern, normalizeURL = u.normalizeURL) {\n this._normalizeURL = normalizeURL;\n this._groups = [];\n const positiveList = [];\n const negativeList = [];\n for (let pattern of u.parseTokens(fullPattern)) {\n if (pattern[0] === '-') {\n negativeList.push(pattern.substring(1));\n }\n else {\n positiveList.push(pattern);\n }\n }\n this._positiveRegexp = this._buildRegexp(positiveList, true);\n this._negativeRegexp = this._buildRegexp(negativeList, false);\n }\n _buildRegexp(list, capture) {\n if (!list.length) {\n return;\n }\n list = list.map((url) => {\n if (url[0] === '*') {\n url = '/' + url;\n }\n url = this._normalizeURL(url);\n url = u.escapeRegExp(url);\n return url;\n });\n let reCode = list.join('|');\n reCode = reCode.replace(/\\\\\\*/g, '.*?');\n reCode = reCode.replace(/(:|\\\\\\$)([a-z][\\w-]*)/ig, (match, type, name) => {\n if (type === '\\\\$') {\n if (capture) {\n this._groups.push({ name, cast: Number });\n }\n return '(\\\\d+)';\n }\n else {\n if (capture) {\n this._groups.push({ name, cast: String });\n }\n return '([^/?#]+)';\n }\n });\n return new RegExp('^(?:' + reCode + ')$');\n }\n test(url, doNormalize = true) {\n if (doNormalize) {\n url = this._normalizeURL(url);\n }\n return this._positiveRegexp.test(url) && !this._isExcluded(url);\n }\n recognize(url, doNormalize = true) {\n if (doNormalize) {\n url = this._normalizeURL(url);\n }\n let match = this._positiveRegexp.exec(url);\n if (match && !this._isExcluded(url)) {\n const resolution = {};\n this._groups.forEach((group, groupIndex) => {\n let value = match[groupIndex + 1];\n if (value) {\n return resolution[group.name] = group.cast(value);\n }\n });\n return resolution;\n }\n }\n _isExcluded(url) {\n return this._negativeRegexp?.test(url);\n }\n};\n\n\n/***/ }),\n/* 80 */\n/***/ (() => {\n\nup.framework = (function () {\n let readyState = 'evaling';\n function emitReset() {\n up.emit('up:framework:reset', { log: false });\n }\n function boot() {\n if (readyState !== 'configuring') {\n console.error('Unpoly has already booted');\n return;\n }\n let issue = supportIssue();\n if (!issue) {\n readyState = 'booting';\n up.emit('up:framework:boot', { log: false });\n readyState = 'booted';\n up.emit('up:framework:booted', { log: false });\n }\n else {\n console.error(\"Unpoly cannot boot: %s\", issue);\n }\n }\n function mustBootManually() {\n let unpolyScript = document.currentScript;\n if (unpolyScript?.async) {\n return true;\n }\n if (unpolyScript?.getAttribute('up-boot') === 'manual') {\n return true;\n }\n if (document.readyState === 'complete') {\n return true;\n }\n }\n function onEvaled() {\n up.emit('up:framework:evaled', { log: false });\n if (mustBootManually()) {\n console.debug('Call up.boot() after you have configured Unpoly');\n }\n else {\n document.addEventListener('DOMContentLoaded', boot);\n }\n readyState = 'configuring';\n }\n function startExtension() {\n if (readyState !== 'configuring') {\n throw new Error('Unpoly extensions must be loaded before booting');\n }\n readyState = 'evaling';\n }\n function stopExtension() {\n readyState = 'configuring';\n }\n function isSupported() {\n return !supportIssue();\n }\n function supportIssue() {\n for (let feature of ['URL', 'Proxy', 'Promise', 'DOMParser', 'FormData']) {\n if (!window[feature]) {\n return `Browser doesn't support the ${feature} API`;\n }\n }\n if (document.compatMode === 'BackCompat') {\n return 'Browser is in quirks mode (missing DOCTYPE?)';\n }\n }\n return {\n onEvaled,\n boot,\n startExtension,\n stopExtension,\n reset: emitReset,\n get evaling() { return readyState === 'evaling'; },\n get booted() { return readyState === 'booted'; },\n get beforeBoot() { return readyState !== 'booting' && readyState !== 'booted'; },\n isSupported,\n };\n})();\nup.boot = up.framework.boot;\n\n\n/***/ }),\n/* 81 */\n/***/ (() => {\n\nup.event = (function () {\n const u = up.util;\n const e = up.element;\n function reset() {\n for (let globalElement of [window, document, e.root, document.body]) {\n for (let listener of up.EventListener.allNonDefault(globalElement)) {\n listener.unbind();\n }\n }\n }\n function on(...args) {\n return buildListenerGroup(args).bind();\n }\n function off(...args) {\n return buildListenerGroup(args).unbind();\n }\n function buildListenerGroup(args, options) {\n return up.EventListenerGroup.fromBindArgs(args, options);\n }\n function buildEmitter(args) {\n return up.EventEmitter.fromEmitArgs(args);\n }\n function emit(...args) {\n return buildEmitter(args).emit();\n }\n function build(...args) {\n const props = u.extractOptions(args);\n const type = args[0] || props.type || up.fail('Expected event type to be passed as string argument or { type } property');\n const event = document.createEvent('Event');\n event.initEvent(type, true, true);\n Object.assign(event, u.omit(props, ['type', 'target']));\n return event;\n }\n function assertEmitted(...args) {\n return buildEmitter(args).assertEmitted();\n }\n function onEscape(listener) {\n return on('keydown', function (event) {\n if (event.key === 'Escape') {\n return listener(event);\n }\n });\n }\n function halt(event, options = {}) {\n if (options.log)\n up.log.putsEvent(event);\n event.stopImmediatePropagation();\n event.preventDefault();\n }\n const keyModifiers = ['metaKey', 'shiftKey', 'ctrlKey', 'altKey'];\n function isUnmodified(event) {\n return (u.isUndefined(event.button) || (event.button === 0)) &&\n !u.some(keyModifiers, modifier => event[modifier]);\n }\n function fork(originalEvent, newType, copyKeys = []) {\n const newEvent = up.event.build(newType, u.pick(originalEvent, copyKeys));\n newEvent.originalEvent = originalEvent;\n ['stopPropagation', 'stopImmediatePropagation', 'preventDefault'].forEach(function (key) {\n const originalMethod = newEvent[key];\n return newEvent[key] = function () {\n originalEvent[key]();\n return originalMethod.call(newEvent);\n };\n });\n if (originalEvent.defaultPrevented) {\n newEvent.preventDefault();\n }\n return newEvent;\n }\n function executeEmitAttr(event, element) {\n if (!isUnmodified(event)) {\n return;\n }\n const eventType = e.attr(element, 'up-emit');\n const eventProps = e.jsonAttr(element, 'up-emit-props');\n const forkedEvent = fork(event, eventType);\n Object.assign(forkedEvent, eventProps);\n up.emit(element, forkedEvent);\n }\n on('up:click', 'a[up-emit]', executeEmitAttr);\n let inputDevices = ['unknown'];\n function getInputDevice() {\n return u.last(inputDevices);\n }\n function observeInputDevice(newModality) {\n inputDevices.push(newModality);\n setTimeout(() => inputDevices.pop());\n }\n on('keydown keyup', { capture: true }, () => observeInputDevice('key'));\n on('pointerdown pointerup', { capture: true }, () => observeInputDevice('pointer'));\n on('up:framework:reset', reset);\n return {\n on,\n off,\n build,\n emit,\n assertEmitted,\n onEscape,\n halt,\n isUnmodified,\n fork,\n keyModifiers,\n get inputDevice() { return getInputDevice(); }\n };\n})();\nup.on = up.event.on;\nup.off = up.event.off;\nup.emit = up.event.emit;\n\n\n/***/ }),\n/* 82 */\n/***/ (() => {\n\nup.protocol = (function () {\n const u = up.util;\n const e = up.element;\n const headerize = function (camel) {\n const header = camel.replace(/(^.|[A-Z])/g, char => '-' + char.toUpperCase());\n return 'X-Up' + header;\n };\n const extractHeader = function (xhr, shortHeader, parseFn = u.identity) {\n let value = xhr.getResponseHeader(headerize(shortHeader));\n if (value) {\n return parseFn(value);\n }\n };\n function targetFromXHR(xhr) {\n return extractHeader(xhr, 'target');\n }\n function parseModifyCacheValue(value) {\n if (value === 'false') {\n return false;\n }\n else {\n return value;\n }\n }\n function evictCacheFromXHR(xhr) {\n return extractHeader(xhr, 'evictCache', parseModifyCacheValue);\n }\n function expireCacheFromXHR(xhr) {\n return extractHeader(xhr, 'expireCache') || up.migrate.clearCacheFromXHR?.(xhr);\n }\n function contextFromXHR(xhr) {\n return extractHeader(xhr, 'context', JSON.parse);\n }\n function methodFromXHR(xhr) {\n return extractHeader(xhr, 'method', u.normalizeMethod);\n }\n function titleFromXHR(xhr) {\n return up.migrate.titleFromXHR?.(xhr) ?? extractHeader(xhr, 'title', JSON.parse);\n }\n function eventPlansFromXHR(xhr) {\n return extractHeader(xhr, 'events', JSON.parse);\n }\n function acceptLayerFromXHR(xhr) {\n return extractHeader(xhr, 'acceptLayer', JSON.parse);\n }\n function dismissLayerFromXHR(xhr) {\n return extractHeader(xhr, 'dismissLayer', JSON.parse);\n }\n const initialRequestMethod = u.memoize(function () {\n return u.normalizeMethod(up.browser.popCookie('_up_method'));\n });\n function locationFromXHR(xhr) {\n return extractHeader(xhr, 'location') || xhr.responseURL;\n }\n function influencingHeadersFromResponse(response) {\n let varyHeaderValue = response.header('Vary');\n return u.parseTokens(varyHeaderValue, { separator: 'comma' });\n }\n const config = new up.Config(() => ({\n methodParam: '_method',\n csrfParam() { return e.metaContent('csrf-param'); },\n csrfToken() { return e.metaContent('csrf-token'); },\n cspNonce() { return e.metaContent('csp-nonce'); },\n csrfHeader: 'X-CSRF-Token',\n maxHeaderSize: 2048,\n }));\n function csrfHeader() {\n return u.evalOption(config.csrfHeader);\n }\n function csrfParam() {\n return u.evalOption(config.csrfParam);\n }\n function csrfToken() {\n return u.evalOption(config.csrfToken);\n }\n function cspNonce() {\n return u.evalOption(config.cspNonce);\n }\n function cspNoncesFromHeader(cspHeader) {\n let nonces = [];\n if (cspHeader) {\n let parts = cspHeader.split(/\\s*;\\s*/);\n for (let part of parts) {\n if (part.indexOf('script-src') === 0) {\n let noncePattern = /'nonce-([^']+)'/g;\n let match;\n while (match = noncePattern.exec(part)) {\n nonces.push(match[1]);\n }\n }\n }\n }\n return nonces;\n }\n function wrapMethod(method, params) {\n params.add(config.methodParam, method);\n return 'POST';\n }\n return {\n config,\n locationFromXHR,\n titleFromXHR,\n targetFromXHR,\n methodFromXHR,\n acceptLayerFromXHR,\n contextFromXHR,\n dismissLayerFromXHR,\n eventPlansFromXHR,\n expireCacheFromXHR,\n evictCacheFromXHR,\n csrfHeader,\n csrfParam,\n csrfToken,\n cspNonce,\n initialRequestMethod,\n headerize,\n wrapMethod,\n cspNoncesFromHeader,\n influencingHeadersFromResponse,\n };\n})();\n\n\n/***/ }),\n/* 83 */\n/***/ (() => {\n\nup.log = (function () {\n const u = up.util;\n const config = new up.LogConfig();\n function printToStandard(...args) {\n if (config.enabled) {\n printToStream('log', ...args);\n }\n }\n const printToWarn = (...args) => printToStream('warn', ...args);\n const printToError = (...args) => printToStream('error', ...args);\n function printToStream(stream, trace, message, ...args) {\n printToStreamStyled(stream, trace, '', message, ...args);\n }\n function printToStreamStyled(stream, trace, customStyles, message, ...args) {\n if (message) {\n if (config.format) {\n console[stream](`%c${trace}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);\n }\n else {\n console[stream](`[${trace}] ${u.sprintf(message, ...args)}`);\n }\n }\n }\n function printUserEvent(event) {\n if (config.enabled) {\n event = event.originalEvent || event;\n let color = '#5566cc';\n printToStreamStyled('log', event.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', event.target);\n }\n }\n function printBanner() {\n if (!config.banner) {\n return;\n }\n const logo = \" __ _____ ___ ___ / /_ __\\n\" +\n `/ // / _ \\\\/ _ \\\\/ _ \\\\/ / // / ${up.version}\\n` +\n \"\\\\___/_//_/ .__/\\\\___/_/\\\\_. / \\n\" +\n \" / / / /\\n\\n\";\n let text = \"\";\n if (!up.migrate.loaded) {\n text += \"Load unpoly-migrate.js to polyfill deprecated APIs.\\n\\n\";\n }\n if (config.enabled) {\n text += \"Call `up.log.disable()` to disable logging for this session.\";\n }\n else {\n text += \"Call `up.log.enable()` to enable logging for this session.\";\n }\n const color = 'color: #777777';\n if (config.format) {\n console.log('%c' + logo + '%c' + text, 'font-family: monospace;' + color, color);\n }\n else {\n console.log(logo + text);\n }\n }\n up.on('up:framework:boot', printBanner);\n function enable() {\n config.enabled = true;\n }\n function disable() {\n config.enabled = false;\n }\n return {\n puts: printToStandard,\n putsEvent: printUserEvent,\n error: printToError,\n warn: printToWarn,\n config,\n enable,\n disable,\n };\n})();\nup.puts = up.log.puts;\nup.warn = up.log.warn;\n\n\n/***/ }),\n/* 84 */\n/***/ (() => {\n\nup.script = (function () {\n const u = up.util;\n const e = up.element;\n const config = new up.Config(() => ({\n assetSelectors: [\n 'link[rel=stylesheet]',\n 'script[src]',\n '[up-asset]'\n ],\n noAssetSelectors: [\n '[up-asset=false]',\n ],\n nonceableAttributes: [\n 'up-watch',\n 'up-on-accepted',\n 'up-on-dismissed',\n 'up-on-loaded',\n 'up-on-rendered',\n 'up-on-finished',\n 'up-on-error',\n 'up-on-offline',\n ],\n scriptSelectors: [\n 'script'\n ],\n noScriptSelectors: [\n 'script[type=\"application/ld+json\"]'\n ]\n }));\n const SYSTEM_MACRO_PRIORITIES = {\n '[up-back]': -100,\n '[up-content]': -200,\n '[up-drawer]': -200,\n '[up-modal]': -200,\n '[up-cover]': -200,\n '[up-popup]': -200,\n '[up-tooltip]': -200,\n '[up-dash]': -200,\n '[up-flashes]': -200,\n '[up-expand]': -300,\n '[data-method]': -400,\n '[data-confirm]': -400,\n };\n let registeredCompilers = [];\n let registeredMacros = [];\n function registerCompiler(...args) {\n const compiler = buildCompiler(args);\n return insertCompiler(registeredCompilers, compiler);\n }\n function registerMacro(...args) {\n const macro = buildCompiler(args);\n if (up.framework.evaling) {\n macro.priority ||= detectSystemMacroPriority(macro.selector) ||\n up.fail('Unregistered priority for system macro %o', macro.selector);\n }\n return insertCompiler(registeredMacros, macro);\n }\n function detectSystemMacroPriority(macroSelector) {\n macroSelector = u.evalOption(macroSelector);\n for (let substr in SYSTEM_MACRO_PRIORITIES) {\n const priority = SYSTEM_MACRO_PRIORITIES[substr];\n if (macroSelector.indexOf(substr) >= 0) {\n return priority;\n }\n }\n }\n const parseCompilerArgs = function (args) {\n const defaults = u.extractOptions(args);\n const selector = args.shift();\n const callback = args.pop();\n const options = { ...defaults, ...u.extractOptions(args) };\n return [selector, options, callback];\n };\n function buildCompiler(args) {\n let [selector, options, callback] = parseCompilerArgs(args);\n options = u.options(options, {\n selector,\n isDefault: up.framework.evaling,\n priority: 0,\n batch: false,\n });\n return Object.assign(callback, options);\n }\n function insertCompiler(queue, newCompiler) {\n let existingCompiler;\n let index = 0;\n while ((existingCompiler = queue[index]) && (existingCompiler.priority >= newCompiler.priority)) {\n index += 1;\n }\n queue.splice(index, 0, newCompiler);\n if (up.framework.booted) {\n if (newCompiler.priority === 0) {\n for (let layer of up.layer.stack) {\n compile(layer.element, { layer, compilers: [newCompiler] });\n }\n }\n else {\n up.puts('up.compiler()', 'Compiler %s was registered after booting Unpoly. Compiler will run for future fragments only.', newCompiler.selector);\n }\n }\n return newCompiler;\n }\n function compile(fragment, options) {\n up.emit(fragment, 'up:fragment:compile', { log: false });\n let compilers = options.compilers || registeredMacros.concat(registeredCompilers);\n const pass = new up.CompilerPass(fragment, compilers, options);\n pass.run();\n }\n function registerDestructor(element, destructor) {\n let destructors = element.upDestructors;\n if (!destructors) {\n destructors = [];\n element.upDestructors = destructors;\n element.classList.add('up-can-clean');\n }\n if (u.isArray(destructor)) {\n destructors.push(...destructor);\n }\n else {\n destructors.push(destructor);\n }\n }\n function hello(element, options = {}) {\n element = up.fragment.get(element, options);\n up.puts('up.hello()', \"Compiling fragment %o\", element);\n compile(element, options);\n up.fragment.emitInserted(element);\n return element;\n }\n function clean(fragment, options = {}) {\n new up.DestructorPass(fragment, options).run();\n }\n function readData(element) {\n element = up.fragment.get(element);\n return element.upData ||= buildData(element);\n }\n function buildData(element) {\n if (!element.getAttribute) {\n return {};\n }\n let rawJSON = element.getAttribute('up-data');\n let parsedJSON;\n if (rawJSON) {\n parsedJSON = JSON.parse(rawJSON);\n if (!u.isOptions(parsedJSON)) {\n return parsedJSON;\n }\n }\n return {\n ...element.dataset,\n ...parsedJSON,\n ...element.upCompileData,\n };\n }\n function findAssets(head = document.head) {\n return head.querySelectorAll(config.selector('assetSelectors'));\n }\n function assertAssetsOK(newAssets, renderOptions) {\n let oldAssets = findAssets();\n let oldHTML = u.map(oldAssets, 'outerHTML').join();\n let newHTML = u.map(newAssets, 'outerHTML').join();\n if (oldHTML !== newHTML) {\n up.event.assertEmitted('up:assets:changed', { oldAssets, newAssets, renderOptions });\n }\n }\n function disableScript(scriptElement) {\n scriptElement.type = 'up-disabled-script';\n }\n function disableScriptsInSubtree(root) {\n let selector = config.selector('scriptSelectors');\n u.each(e.subtree(root, selector), disableScript);\n }\n function reset() {\n registeredCompilers = u.filter(registeredCompilers, 'isDefault');\n registeredMacros = u.filter(registeredMacros, 'isDefault');\n }\n up.on('up:framework:reset', reset);\n return {\n config,\n compiler: registerCompiler,\n macro: registerMacro,\n destructor: registerDestructor,\n hello,\n clean,\n data: readData,\n findAssets,\n assertAssetsOK,\n disableSubtree: disableScriptsInSubtree,\n };\n})();\nup.compiler = up.script.compiler;\nup.destructor = up.script.destructor;\nup.macro = up.script.macro;\nup.data = up.script.data;\nup.hello = up.script.hello;\n\n\n/***/ }),\n/* 85 */\n/***/ (() => {\n\nup.history = (function () {\n const u = up.util;\n const e = up.element;\n const config = new up.Config(() => ({\n enabled: true,\n updateMetaTags: true,\n restoreTargets: ['body'],\n metaTagSelectors: [\n 'meta',\n 'link[rel=alternate]',\n 'link[rel=canonical]',\n 'link[rel=icon]',\n '[up-meta]',\n 'script[type=\"application/ld+json\"]',\n ],\n noMetaTagSelectors: [\n 'meta[http-equiv]',\n '[up-meta=false]',\n 'meta[name=csp-nonce]',\n ],\n }));\n let previousLocation;\n let nextPreviousLocation;\n function reset() {\n previousLocation = undefined;\n nextPreviousLocation = undefined;\n trackCurrentLocation();\n }\n const DEFAULT_NORMALIZE_OPTIONS = { hash: true };\n function normalizeURL(url, options) {\n options = u.merge(DEFAULT_NORMALIZE_OPTIONS, options);\n return u.normalizeURL(url, options);\n }\n function currentLocation(normalizeOptions) {\n return normalizeURL(location.href, normalizeOptions);\n }\n function trackCurrentLocation() {\n const url = currentLocation();\n if (nextPreviousLocation !== url) {\n previousLocation = nextPreviousLocation;\n nextPreviousLocation = url;\n }\n }\n trackCurrentLocation();\n const ADDITIONAL_NORMALIZE_OPTIONS_FOR_COMPARISON = { trailingSlash: false };\n function isLocation(url, options) {\n options = u.merge(ADDITIONAL_NORMALIZE_OPTIONS_FOR_COMPARISON, options);\n return normalizeURL(url, options) === currentLocation(options);\n }\n function replace(location, options = {}) {\n location = normalizeURL(location);\n if (manipulate('replaceState', location) && (options.event !== false)) {\n emitLocationChanged({ location, reason: 'replace', log: `Replaced state for ${location}` });\n }\n }\n function push(location) {\n location = normalizeURL(location);\n if (!isLocation(location) && manipulate('pushState', location)) {\n emitLocationChanged({ location, reason: 'push', log: `Advanced to location ${location}` });\n }\n }\n function emitLocationChanged(props) {\n let event = up.event.build('up:location:changed', props);\n up.migrate?.renamedProperty?.(event, 'url', 'location');\n up.emit(event);\n }\n function manipulate(method, url) {\n if (config.enabled) {\n const state = buildState();\n window.history[method](state, '', url);\n trackCurrentLocation();\n return true;\n }\n }\n function buildState() {\n return { up: {} };\n }\n function restoreStateOnPop(state) {\n if (!state?.up) {\n up.puts('popstate', 'Ignoring a history state not owned by Unpoly');\n return;\n }\n let location = currentLocation();\n if (up.emit('up:location:restore', { location, log: `Restoring location ${location}` }).defaultPrevented) {\n return;\n }\n up.render({\n url: location,\n target: config.restoreTargets,\n fail: false,\n history: true,\n location,\n peel: true,\n layer: 'root',\n cache: true,\n saveScroll: false,\n scroll: ['restore', 'auto'],\n saveFocus: false,\n focus: ['restore', 'auto'],\n });\n }\n function onPop(event) {\n trackCurrentLocation();\n let location = currentLocation();\n emitLocationChanged({ location, reason: 'pop', log: `Navigated to history entry ${location}` });\n up.viewport.saveFocus({ location: previousLocation });\n up.viewport.saveScroll({ location: previousLocation });\n restoreStateOnPop(event.state);\n }\n function register() {\n window.addEventListener('popstate', onPop);\n if (up.protocol.initialRequestMethod() === 'GET') {\n replace(currentLocation(), { event: false });\n }\n }\n up.on('up:framework:boot', function () {\n if ('jasmine' in window) {\n register();\n }\n else {\n setTimeout(register, 100);\n }\n });\n function findMetaTags(head = document.head) {\n return head.querySelectorAll(config.selector('metaTagSelectors'));\n }\n function updateMetaTags(newMetaTags) {\n let oldMetaTags = findMetaTags();\n for (let oldMetaTag of oldMetaTags) {\n oldMetaTag.remove();\n }\n for (let newMetaTag of newMetaTags) {\n document.head.append(newMetaTag);\n }\n }\n up.macro('a[up-back], [up-href][up-back]', function (link) {\n if (previousLocation) {\n e.setMissingAttrs(link, {\n 'up-href': previousLocation,\n 'up-scroll': 'restore'\n });\n link.removeAttribute('up-back');\n up.link.makeFollowable(link);\n }\n });\n up.on('up:framework:reset', reset);\n return {\n config,\n push,\n replace,\n get location() { return currentLocation(); },\n get previousLocation() { return previousLocation; },\n normalizeURL,\n isLocation,\n findMetaTags,\n updateMetaTags,\n };\n})();\n\n\n/***/ }),\n/* 86 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(87);\nconst u = up.util;\nconst e = up.element;\nup.fragment = (function () {\n function upTagName(element) {\n let tagName = e.tagName(element);\n if (tagName.startsWith('up-')) {\n return tagName;\n }\n }\n const config = new up.Config(() => ({\n badTargetClasses: [/^up-/],\n targetDerivers: [\n '[up-id]',\n '[id]',\n 'html',\n 'head',\n 'body',\n 'main',\n '[up-main]',\n upTagName,\n 'link[rel][type]',\n 'link[rel=preload][href]',\n 'link[rel=preconnect][href]',\n 'link[rel=prefetch][href]',\n 'link[rel]',\n 'meta[property]',\n '*[name]',\n 'form[action]',\n 'a[href]',\n '[class]',\n '[up-flashes]',\n 'form',\n ],\n verifyDerivedTarget: true,\n navigateOptions: {\n cache: 'auto',\n revalidate: 'auto',\n feedback: true,\n fallback: true,\n focus: 'auto',\n scroll: 'auto',\n history: 'auto',\n peel: true,\n },\n match: 'region',\n runScripts: true,\n autoHistoryTargets: [':main'],\n autoFocus: ['hash', 'autofocus', 'main-if-main', 'keep', 'target-if-lost'],\n autoScroll: ['hash', 'layer-if-main'],\n autoRevalidate: (response) => response.expired,\n skipResponse: defaultSkipResponse\n }));\n u.delegate(config, ['mainTargets'], () => up.layer.config.any);\n function defaultSkipResponse({ response, expiredResponse }) {\n return !response.text || response.text === expiredResponse?.text;\n }\n function sourceOf(element, options = {}) {\n element = getSmart(element, options);\n return e.closestAttr(element, 'up-source');\n }\n function timeOf(element) {\n let value = e.closestAttr(element, 'up-time');\n if (value && value !== 'false') {\n if (/^\\d+$/.test(value)) {\n value = Number(value) * 1000;\n }\n return new Date(value);\n }\n }\n function etagOf(element) {\n let value = e.closestAttr(element, 'up-etag');\n if (value && value !== 'false') {\n return value;\n }\n }\n const render = up.mockable((...args) => {\n let options = parseTargetAndOptions(args);\n return new up.RenderJob(options).execute();\n });\n const navigate = up.mockable((...args) => {\n const options = parseTargetAndOptions(args);\n return render({ ...options, navigate: true });\n });\n function emitFragmentInserted(element) {\n return up.emit(element, 'up:fragment:inserted', {\n log: ['Inserted fragment %o', element],\n });\n }\n function emitFragmentKeep(keepPlan) {\n let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;\n const log = ['Keeping fragment %o', oldElement];\n const callback = e.callbackAttr(oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });\n return up.emit(oldElement, 'up:fragment:keep', { newFragment, newData, renderOptions, log, callback });\n }\n function emitFragmentDestroyed(fragment, options) {\n const log = options.log ?? ['Destroyed fragment %o', fragment];\n const parent = options.parent || document;\n return up.emit(parent, 'up:fragment:destroyed', { fragment, parent, log });\n }\n function isNotDestroying(element) {\n return !element.closest('.up-destroying');\n }\n function isAlive(fragment) {\n return fragment.isConnected && isNotDestroying(fragment);\n }\n function getSmart(...args) {\n const options = u.extractOptions(args);\n const selector = args.pop();\n const root = args[0];\n if (u.isElementish(selector)) {\n return e.get(selector);\n }\n if (root) {\n return getDumb(root, selector, options);\n }\n return new up.FragmentFinder({\n selector,\n origin: options.origin,\n layer: options.layer,\n match: options.match,\n }).find();\n }\n function getDumb(...args) {\n return getAll(...args)[0];\n }\n function getAll(...args) {\n const options = u.extractOptions(args);\n let selectorString = args.pop();\n const root = args[0];\n if (u.isElement(selectorString)) {\n return [selectorString];\n }\n if (u.isList(selectorString)) {\n return selectorString;\n }\n let selector = new up.Selector(selectorString, root, options);\n return selector.descendants(root);\n }\n function getSubtree(element, selector, options = {}) {\n return new up.Selector(selector, element, options).subtree(element);\n }\n function contains(root, selectorOrElement) {\n if (u.isElement(selectorOrElement)) {\n return e.contains(root, selectorOrElement) && up.layer.get(root).contains(selectorOrElement);\n }\n else {\n return getSubtree(root, selectorOrElement).length > 0;\n }\n }\n function closest(element, selector, options) {\n return new up.Selector(selector, element, options).closest(element);\n }\n function destroy(...args) {\n const options = parseTargetAndOptions(args);\n if (options.element = getSmart(options.target, options)) {\n new up.Change.DestroyFragment(options).execute();\n }\n return up.migrate.formerlyAsync?.('up.destroy()');\n }\n function parseTargetAndOptions(args) {\n const options = u.parseArgIntoOptions(args, 'target');\n if (u.isElement(options.target)) {\n options.origin ||= options.target;\n }\n return options;\n }\n function markFragmentAsDestroying(element) {\n element.classList.add('up-destroying');\n element.setAttribute('aria-hidden', 'true');\n }\n function reload(...args) {\n const options = parseTargetAndOptions(args);\n options.target ||= ':main';\n const element = getSmart(options.target, options);\n options.url ||= sourceOf(element);\n options.headers = u.merge(options.headers, conditionalHeaders(element));\n if (options.keepData || e.booleanAttr(element, 'up-keep-data')) {\n options.data = up.data(element);\n }\n up.migrate.postprocessReloadOptions?.(options);\n return render(options);\n }\n function conditionalHeaders(element) {\n let headers = {};\n let time = timeOf(element);\n if (time) {\n headers['If-Modified-Since'] = time.toUTCString();\n }\n let etag = etagOf(element);\n if (etag) {\n headers['If-None-Match'] = etag;\n }\n return headers;\n }\n function visit(url, options) {\n return navigate({ ...options, url });\n }\n const KEY_PATTERN = /^(onFail|on|fail)?(.+)$/;\n function successKey(key) {\n let match = KEY_PATTERN.exec(key);\n if (match) {\n let [_, prefix, suffix] = match;\n switch (prefix) {\n case 'onFail':\n return 'on' + u.upperCaseFirst(suffix);\n case 'fail':\n return u.lowerCaseFirst(suffix);\n }\n }\n }\n function failKey(key) {\n let match = KEY_PATTERN.exec(key);\n if (match) {\n let [_, prefix, suffix] = match;\n switch (prefix) {\n case 'on':\n return 'onFail' + u.upperCaseFirst(suffix);\n case undefined:\n return 'fail' + u.upperCaseFirst(suffix);\n }\n }\n }\n function toTarget(element, options) {\n return u.presence(element, u.isString) || tryToTarget(element, options) || cannotTarget(element);\n }\n function isTargetable(element) {\n return !!tryToTarget(element);\n }\n function untargetableMessage(element) {\n return `Cannot derive good target selector from a <${e.tagName(element)}> element without identifying attributes. Try setting an [id] or configure up.fragment.config.targetDerivers.`;\n }\n function cannotTarget(element) {\n throw new up.CannotTarget(untargetableMessage(element));\n }\n function tryToTarget(element, options) {\n return u.findResult(config.targetDerivers, function (deriver) {\n let target = deriveTarget(element, deriver);\n if (target && isGoodTarget(target, element, options)) {\n return target;\n }\n });\n }\n function deriveTarget(element, deriver) {\n if (u.isFunction(deriver)) {\n return deriver(element);\n }\n else if (element.matches(deriver)) {\n try {\n return deriveTargetFromPattern(element, deriver);\n }\n catch (e) {\n if (e instanceof up.CannotParse) {\n return deriver;\n }\n else {\n throw e;\n }\n }\n }\n }\n function deriveTargetFromPattern(element, deriver) {\n let { includePath, excludeRaw } = up.element.parseSelector(deriver);\n if (includePath.length !== 1) {\n throw new up.CannotParse(deriver);\n }\n let { tagName, id, classNames, attributes } = includePath[0];\n let result = '';\n if (tagName === '*') {\n result += e.tagName(element);\n }\n else if (tagName) {\n result += tagName;\n }\n for (let className of classNames) {\n result += e.classSelector(className);\n }\n if (id) {\n result += e.idSelector(id);\n }\n for (let attributeName in attributes) {\n let attributeValue = attributes[attributeName] || element.getAttribute(attributeName);\n if (attributeName === 'id') {\n result += e.idSelector(attributeValue);\n }\n else if (attributeName === 'class') {\n for (let goodClass of goodClassesForTarget(element)) {\n result += e.classSelector(goodClass);\n }\n }\n else {\n result += e.attrSelector(attributeName, attributeValue);\n }\n }\n if (excludeRaw) {\n result += excludeRaw;\n }\n return result;\n }\n function isGoodTarget(target, element, options = {}) {\n return !isAlive(element) || !config.verifyDerivedTarget || up.fragment.get(target, { layer: element, ...options }) === element;\n }\n function matchesPattern(pattern, str) {\n if (u.isRegExp(pattern)) {\n return pattern.test(str);\n }\n else {\n return pattern === str;\n }\n }\n function goodClassesForTarget(element) {\n let isGood = (klass) => !u.some(config.badTargetClasses, (badTargetClass) => matchesPattern(badTargetClass, klass));\n return u.filter(element.classList, isGood);\n }\n const MAIN_PSEUDO = /:main\\b/;\n const LAYER_PSEUDO = /:layer\\b/;\n const ORIGIN_PSEUDO = /:origin\\b/;\n function containsMainPseudo(target) {\n return MAIN_PSEUDO.test(target);\n }\n function expandTargets(targets, options = {}) {\n const { layer } = options;\n if (layer !== 'new' && !(layer instanceof up.Layer)) {\n up.fail('Must pass an up.Layer as { layer } option, but got %o', layer);\n }\n targets = u.copy(u.wrapList(targets));\n const expanded = [];\n while (targets.length) {\n let target = targets.shift();\n if (target === true)\n target = ':main';\n if (containsMainPseudo(target)) {\n let mode = resolveMode(options);\n let replaced = up.layer.mainTargets(mode).map((mainTarget) => target.replace(MAIN_PSEUDO, mainTarget));\n targets.unshift(...replaced);\n }\n else if (LAYER_PSEUDO.test(target)) {\n if (layer === 'new' || layer.opening)\n continue;\n let firstSwappableTarget = toTarget(layer.getFirstSwappableElement(), options);\n targets.unshift(target.replace(LAYER_PSEUDO, firstSwappableTarget));\n }\n else if (u.isElementish(target)) {\n expanded.push(toTarget(target, options));\n }\n else if (u.isString(target)) {\n expanded.push(resolveOrigin(target, options));\n }\n }\n return u.uniq(expanded);\n }\n function resolveMode({ layer, mode }) {\n if (layer === 'new') {\n return mode || up.fail('Must pass a { mode } option together with { layer: \"new\" }');\n }\n else {\n return layer.mode;\n }\n }\n function modernResolveOrigin(target, { origin } = {}) {\n return target.replace(ORIGIN_PSEUDO, function (match) {\n if (origin) {\n return toTarget(origin);\n }\n else {\n up.fail('Missing { origin } element to resolve \"%s\" reference (found in %s)', match, target);\n }\n });\n }\n function resolveOrigin(...args) {\n return (up.migrate.resolveOrigin || modernResolveOrigin)(...args);\n }\n function splitTarget(target) {\n return u.parseTokens(target, { separator: 'comma' });\n }\n function parseTargetSteps(target, options = {}) {\n let defaultPlacement = options.defaultPlacement || 'swap';\n let defaultMaybe = options.defaultMaybe ?? false;\n let steps = [];\n let simpleSelectors = splitTarget(target);\n for (let selector of simpleSelectors) {\n if (selector === ':none')\n continue;\n let placement = defaultPlacement;\n let maybe = defaultMaybe;\n selector = selector.replace(/\\b::?(before|after)\\b/, (_match, customPlacement) => {\n placement = customPlacement;\n return '';\n });\n selector = selector.replace(/\\b:maybe\\b/, () => {\n maybe = true;\n return '';\n });\n const step = {\n ...options,\n selector,\n placement,\n maybe,\n originalRenderOptions: options,\n };\n steps.push(step);\n }\n return steps;\n }\n function hasAutoHistory(newFragments, layer) {\n let vanillaSelector = expandTargets(config.autoHistoryTargets, { layer }).join();\n for (let newFragment of newFragments) {\n if (e.subtree(newFragment, vanillaSelector).length) {\n return true;\n }\n }\n up.puts('up.render()', \"Will not auto-update history because fragment doesn't contain a selector from up.fragment.config.autoHistoryTargets\");\n return false;\n }\n function matches(element, selector, options = {}) {\n element = e.get(element);\n if (u.isElement(selector)) {\n let target = tryToTarget(selector);\n return target && element.matches(target);\n }\n else {\n return new up.Selector(selector, element, options).matches(element);\n }\n }\n function shouldRevalidate(request, response, options = {}) {\n return request.fromCache && u.evalAutoOption(options.revalidate, config.autoRevalidate, response);\n }\n function targetForSteps(steps) {\n let bestSteps = steps.filter((step) => !step.maybe || step.oldElement?.isConnected);\n let selectors = u.map(bestSteps, 'selector');\n return selectors.join(', ') || ':none';\n }\n function isContainedByRivalStep(steps, candidateStep) {\n return u.some(steps, function (rivalStep) {\n return (rivalStep !== candidateStep) &&\n ((rivalStep.placement === 'swap') || (rivalStep.placement === 'content')) &&\n rivalStep.oldElement.contains(candidateStep.oldElement);\n });\n }\n function compressNestedSteps(steps) {\n if (steps.length < 2)\n return steps;\n let compressed = u.uniqBy(steps, 'oldElement');\n compressed = u.reject(compressed, step => isContainedByRivalStep(compressed, step));\n return compressed;\n }\n function abort(...args) {\n let options = parseTargetAndOptions(args);\n let testFn;\n let { reason, newLayer } = options;\n let elements;\n if (options.target) {\n elements = getAll(options.target, options);\n testFn = (request) => request.isPartOfSubtree(elements);\n reason ||= 'Aborting requests within fragment';\n }\n else {\n let layers = up.layer.getAll(options);\n elements = u.map(layers, 'element');\n testFn = (request) => u.contains(layers, request.layer);\n reason ||= 'Aborting requests within ' + layers.join(', ');\n }\n let testFnWithAbortable = (request) => request.abortable && testFn(request);\n up.network.abort(testFnWithAbortable, { ...options, reason });\n for (let element of elements) {\n up.emit(element, 'up:fragment:aborted', { reason, newLayer, log: false });\n }\n }\n function onAborted(fragment, callback) {\n let guard = (event) => event.target.contains(fragment);\n let unsubscribe = up.on('up:fragment:aborted', { guard }, callback);\n up.destructor(fragment, unsubscribe);\n return unsubscribe;\n }\n up.on('up:framework:boot', function () {\n const { documentElement } = document;\n documentElement.setAttribute('up-source', u.normalizeURL(location.href, { hash: false }));\n up.hello(documentElement);\n if (!up.browser.canPushState()) {\n return up.warn('Cannot push history changes. Next fragment update will load in a new page.');\n }\n });\n return {\n config,\n reload,\n destroy,\n render,\n navigate,\n get: getSmart,\n getDumb,\n all: getAll,\n subtree: getSubtree,\n contains,\n closest,\n source: sourceOf,\n visit,\n markAsDestroying: markFragmentAsDestroying,\n emitInserted: emitFragmentInserted,\n emitDestroyed: emitFragmentDestroyed,\n emitKeep: emitFragmentKeep,\n successKey,\n failKey,\n expandTargets,\n resolveOrigin,\n toTarget,\n tryToTarget,\n isTargetable,\n matches,\n hasAutoHistory,\n time: timeOf,\n etag: etagOf,\n shouldRevalidate,\n abort,\n onAborted,\n splitTarget,\n parseTargetSteps,\n isAlive,\n isNotDestroying,\n targetForSteps,\n compressNestedSteps,\n containsMainPseudo,\n };\n})();\nup.reload = up.fragment.reload;\nup.destroy = up.fragment.destroy;\nup.render = up.fragment.render;\nup.navigate = up.fragment.navigate;\nup.visit = up.fragment.visit;\nu.delegate(up, ['context'], () => up.layer.current);\n\n\n/***/ }),\n/* 87 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 88 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(89);\nup.viewport = (function () {\n const u = up.util;\n const e = up.element;\n const f = up.fragment;\n const config = new up.Config(() => ({\n viewportSelectors: ['[up-viewport]', '[up-fixed]'],\n fixedTopSelectors: ['[up-fixed~=top]'],\n fixedBottomSelectors: ['[up-fixed~=bottom]'],\n anchoredRightSelectors: ['[up-anchored~=right]', '[up-fixed~=top]', '[up-fixed~=bottom]', '[up-fixed~=right]'],\n revealSnap: 200,\n revealPadding: 0,\n revealTop: false,\n revealMax() { return 0.5 * window.innerHeight; },\n autoFocusVisible({ element, inputDevice }) { return inputDevice === 'key' || up.form.isField(element); }\n }));\n const bodyShifter = new up.BodyShifter();\n up.compiler(config.selectorFn('anchoredRightSelectors'), function (element) {\n return bodyShifter.onAnchoredElementInserted(element);\n });\n function reveal(element, options) {\n options = u.options(options);\n element = f.get(element, options);\n if (!(options.layer = up.layer.get(element))) {\n up.fail('Cannot reveal a detached element');\n }\n if (options.peel) {\n options.layer.peel();\n }\n const motion = new up.RevealMotion(element, options);\n motion.start();\n return up.migrate.formerlyAsync?.('up.reveal()') || true;\n }\n function doFocus(element, { preventScroll, force, inputDevice, focusVisible } = {}) {\n if (force) {\n if (!element.hasAttribute('tabindex') && element.tabIndex === -1) {\n element.setAttribute('tabindex', '-1');\n }\n }\n inputDevice ??= up.event.inputDevice;\n focusVisible ??= 'auto';\n focusVisible = u.evalAutoOption(focusVisible, config.autoFocusVisible, { element, inputDevice });\n element.focus({\n preventScroll: true,\n focusVisible,\n });\n removeFocusClasses(element);\n element.classList.add(focusVisible ? 'up-focus-visible' : 'up-focus-hidden');\n if (!preventScroll) {\n return reveal(element);\n }\n }\n function removeFocusClasses(element) {\n element?.classList.remove('up-focus-hidden', 'up-focus-visible');\n }\n up.on('focusin', function ({ relatedTarget }) {\n removeFocusClasses(relatedTarget);\n });\n function tryFocus(element, options) {\n doFocus(element, options);\n return element === document.activeElement;\n }\n function revealHash(hash = location.hash, options) {\n let match = firstHashTarget(hash, options);\n if (match) {\n return up.reveal(match, { top: true });\n }\n }\n function allSelector() {\n return [rootSelector(), ...config.viewportSelectors].join();\n }\n function closest(target, options = {}) {\n const element = f.get(target, options);\n return element.closest(allSelector());\n }\n function getSubtree(element, options = {}) {\n element = f.get(element, options);\n return e.subtree(element, allSelector());\n }\n function getAround(element, options = {}) {\n element = f.get(element, options);\n return e.around(element, allSelector());\n }\n function getAll(options = {}) {\n return f.all(allSelector(), options);\n }\n function rootSelector() {\n return getRoot().tagName;\n }\n function getRoot() {\n return document.scrollingElement;\n }\n function rootWidth() {\n return e.root.clientWidth;\n }\n function rootHeight() {\n return e.root.clientHeight;\n }\n function isRoot(element) {\n return element === getRoot();\n }\n function rootHasReducedWidthFromScrollbar() {\n return window.innerWidth > document.documentElement.offsetWidth;\n }\n function rootOverflowElement() {\n const { body } = document;\n const html = document.documentElement;\n const element = u.find([html, body], wasChosenAsOverflowingElement);\n return element || getRoot();\n }\n function wasChosenAsOverflowingElement(element) {\n const overflowY = e.style(element, 'overflow-y');\n return overflowY === 'auto' || overflowY === 'scroll';\n }\n const scrollbarWidth = u.memoize(function () {\n const outerStyle = {\n position: 'absolute',\n top: '0',\n left: '0',\n width: '100px',\n height: '100px',\n overflowY: 'scroll'\n };\n const outer = up.element.affix(document.body, '[up-viewport]', { style: outerStyle });\n const width = outer.offsetWidth - outer.clientWidth;\n outer.remove();\n return width;\n });\n function scrollTopKey(viewport) {\n return up.fragment.tryToTarget(viewport);\n }\n function fixedElements(root = document) {\n const queryParts = ['[up-fixed]'].concat(config.fixedTopSelectors).concat(config.fixedBottomSelectors);\n return root.querySelectorAll(queryParts.join());\n }\n function saveScroll(...args) {\n const [viewports, options] = parseOptions(args);\n const location = options.location || options.layer.location;\n if (location) {\n const tops = getScrollTopsForSave(viewports);\n options.layer.lastScrollTops.set(location, tops);\n }\n }\n function getScrollTopsForSave(viewports) {\n let tops = {};\n for (let viewport of viewports) {\n let key = scrollTopKey(viewport);\n if (key) {\n tops[key] = viewport.scrollTop;\n }\n else {\n up.warn('up.viewport.saveScroll()', 'Cannot save scroll positions for untargetable viewport %o', viewport);\n }\n }\n return tops;\n }\n function restoreScroll(...args) {\n const [viewports, options] = parseOptions(args);\n const { location } = options.layer;\n const locationScrollTops = options.layer.lastScrollTops.get(location);\n if (locationScrollTops) {\n setScrollTops(viewports, locationScrollTops);\n up.puts('up.viewport.restoreScroll()', 'Restored scroll positions to %o', locationScrollTops);\n return true;\n }\n else {\n return false;\n }\n }\n function saveFocus(options = {}) {\n const layer = up.layer.get(options);\n const location = options.location || layer.location;\n if (location) {\n const focusCapsule = up.FocusCapsule.preserve(layer);\n layer.lastFocusCapsules.set(location, focusCapsule);\n }\n }\n function restoreFocus(options = {}) {\n const layer = up.layer.get(options);\n const location = options.location || layer.location;\n const locationCapsule = options.layer.lastFocusCapsules.get(location);\n if (locationCapsule && locationCapsule.restore(layer)) {\n up.puts('up.viewport.restoreFocus()', 'Restored focus to \"%s\"', locationCapsule.target);\n return true;\n }\n else {\n return false;\n }\n }\n function newStateCache() {\n return new up.FIFOCache({ capacity: 30, normalizeKey: up.history.normalizeURL });\n }\n function parseOptions(args) {\n const options = u.copy(u.extractOptions(args));\n options.layer = up.layer.get(options);\n let viewports;\n if (args[0]) {\n viewports = [closest(args[0], options)];\n }\n else if (options.around) {\n viewports = getAround(options.around, options);\n }\n else {\n viewports = getAll(options);\n }\n return [viewports, options];\n }\n function resetScroll(...args) {\n const [viewports, _options] = parseOptions(args);\n setScrollTops(viewports, {});\n }\n function setScrollTops(viewports, tops) {\n for (let viewport of viewports) {\n const key = scrollTopKey(viewport);\n viewport.scrollTop = tops[key] || 0;\n }\n }\n function absolutize(element, options = {}) {\n const viewport = closest(element);\n const viewportRect = viewport.getBoundingClientRect();\n const originalRect = element.getBoundingClientRect();\n const boundsRect = new up.Rect({\n left: originalRect.left - viewportRect.left,\n top: originalRect.top - viewportRect.top,\n width: originalRect.width,\n height: originalRect.height\n });\n options.afterMeasure?.();\n e.setStyle(element, {\n position: element.style.position === 'static' ? 'static' : 'relative',\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto',\n width: '100%',\n height: '100%'\n });\n const bounds = e.createFromSelector('up-bounds');\n e.insertBefore(element, bounds);\n bounds.appendChild(element);\n const moveBounds = function (diffX, diffY) {\n boundsRect.left += diffX;\n boundsRect.top += diffY;\n return e.setStyle(bounds, boundsRect);\n };\n moveBounds(0, 0);\n const newElementRect = element.getBoundingClientRect();\n moveBounds(originalRect.left - newElementRect.left, originalRect.top - newElementRect.top);\n u.each(fixedElements(element), e.fixedToAbsolute);\n return {\n bounds,\n moveBounds\n };\n }\n function firstHashTarget(hash, options = {}) {\n if (hash = pureHash(hash)) {\n const selector = [\n e.attrSelector('id', hash),\n 'a' + e.attrSelector('name', hash)\n ].join();\n return f.get(selector, options);\n }\n }\n function pureHash(value) {\n return value?.replace(/^#/, '');\n }\n function focusedElementWithin(scopeElement) {\n const focusedElement = document.activeElement;\n if (up.fragment.contains(scopeElement, focusedElement)) {\n return focusedElement;\n }\n }\n const CURSOR_PROPS = ['selectionStart', 'selectionEnd', 'scrollLeft', 'scrollTop'];\n function copyCursorProps(from, to = {}) {\n for (let key of CURSOR_PROPS) {\n try {\n to[key] = from[key];\n }\n catch (error) {\n }\n }\n return to;\n }\n let userScrolled = false;\n up.on('scroll', { once: true, beforeBoot: true }, () => userScrolled = true);\n up.on('up:framework:boot', function () {\n u.task(function () {\n if (!userScrolled) {\n return revealHash();\n }\n });\n });\n up.on(window, 'hashchange', () => revealHash());\n return {\n reveal,\n revealHash,\n firstHashTarget,\n config,\n get: closest,\n subtree: getSubtree,\n around: getAround,\n get root() { return getRoot(); },\n rootWidth,\n rootHeight,\n rootHasReducedWidthFromScrollbar,\n rootOverflowElement,\n isRoot,\n scrollbarWidth,\n saveScroll,\n restoreScroll,\n resetScroll,\n saveFocus,\n restoreFocus,\n absolutize,\n focus: doFocus,\n tryFocus,\n newStateCache,\n focusedElementWithin,\n copyCursorProps,\n bodyShifter,\n };\n})();\nup.focus = up.viewport.focus;\nup.reveal = up.viewport.reveal;\n\n\n/***/ }),\n/* 89 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 90 */\n/***/ (() => {\n\nup.motion = (function () {\n const u = up.util;\n const e = up.element;\n let namedAnimations = {};\n let namedTransitions = {};\n const motionController = new up.MotionController('motion');\n const config = new up.Config(() => ({\n duration: 175,\n easing: 'ease',\n enabled: !matchMedia('(prefers-reduced-motion: reduce)').matches\n }));\n function pickDefault(registry) {\n return u.pickBy(registry, 'isDefault');\n }\n function reset() {\n motionController.reset();\n namedAnimations = pickDefault(namedAnimations);\n namedTransitions = pickDefault(namedTransitions);\n }\n function isEnabled() {\n return config.enabled;\n }\n function animate(element, animation, options) {\n element = up.fragment.get(element);\n options = u.options(options);\n let animationFn = findAnimationFn(animation);\n const willRun = willAnimate(element, animation, options);\n animationFn = up.error.guardFn(animationFn);\n if (willRun) {\n const runNow = () => animationFn(element, options);\n return motionController.startFunction(element, runNow, options);\n }\n else {\n return skipAnimate(element, animation);\n }\n }\n function willAnimate(element, animationOrTransition, options) {\n applyConfig(options);\n return isEnabled() && !isNone(animationOrTransition) && (options.duration > 0) && !e.isSingleton(element);\n }\n function skipAnimate(element, animation) {\n if (u.isOptions(animation)) {\n e.setStyle(element, animation);\n }\n return Promise.resolve();\n }\n function animateNow(element, lastFrame, options) {\n options = { ...options, finishEvent: motionController.finishEvent };\n const cssTransition = new up.CSSTransition(element, lastFrame, options);\n return cssTransition.start();\n }\n function applyConfig(options) {\n options.easing ||= config.easing;\n options.duration ||= config.duration;\n }\n function findNamedAnimation(name) {\n return namedAnimations[name] || up.fail(\"Unknown animation %o\", name);\n }\n function finish(element) {\n return motionController.finish(element);\n }\n function morph(oldElement, newElement, transitionObject, options) {\n options = u.options(options);\n applyConfig(options);\n oldElement = up.fragment.get(oldElement);\n newElement = up.fragment.get(newElement);\n let transitionFn = findTransitionFn(transitionObject);\n const willMorph = willAnimate(oldElement, transitionFn, options);\n transitionFn = up.error.guardFn(transitionFn);\n const beforeStart = u.pluckKey(options, 'beforeStart') || u.noop;\n const afterInsert = u.pluckKey(options, 'afterInsert') || u.noop;\n const beforeDetach = u.pluckKey(options, 'beforeDetach') || u.noop;\n const afterDetach = u.pluckKey(options, 'afterDetach') || u.noop;\n const scrollNew = u.pluckKey(options, 'scrollNew') || u.noop;\n beforeStart();\n if (willMorph) {\n if (motionController.isActive(oldElement) && (options.trackMotion === false)) {\n return transitionFn(oldElement, newElement, options);\n }\n up.puts('up.morph()', 'Morphing %o to %o with transition %O over %d ms', oldElement, newElement, transitionObject, options.duration);\n const viewport = up.viewport.get(oldElement);\n const scrollTopBeforeReveal = viewport.scrollTop;\n const oldRemote = up.viewport.absolutize(oldElement, {\n afterMeasure() {\n e.insertBefore(oldElement, newElement);\n afterInsert();\n }\n });\n const trackable = async function () {\n scrollNew();\n const scrollTopAfterReveal = viewport.scrollTop;\n oldRemote.moveBounds(0, scrollTopAfterReveal - scrollTopBeforeReveal);\n await transitionFn(oldElement, newElement, options);\n beforeDetach();\n oldRemote.bounds.remove();\n afterDetach();\n };\n return motionController.startFunction([oldElement, newElement], trackable, options);\n }\n else {\n beforeDetach();\n swapElementsDirectly(oldElement, newElement);\n afterInsert();\n afterDetach();\n scrollNew();\n return Promise.resolve();\n }\n }\n function findTransitionFn(object) {\n if (isNone(object)) {\n return undefined;\n }\n else if (u.isFunction(object)) {\n return object;\n }\n else if (u.isArray(object)) {\n return composeTransitionFn(...object);\n }\n else if (u.isString(object)) {\n let namedTransition;\n if (object.indexOf('/') >= 0) {\n return composeTransitionFn(...object.split('/'));\n }\n else if (namedTransition = namedTransitions[object]) {\n return findTransitionFn(namedTransition);\n }\n }\n else {\n up.fail(\"Unknown transition %o\", object);\n }\n }\n function composeTransitionFn(oldAnimation, newAnimation) {\n if (!isNone(oldAnimation) && !isNone(newAnimation)) {\n const oldAnimationFn = findAnimationFn(oldAnimation) || u.asyncNoop;\n const newAnimationFn = findAnimationFn(newAnimation) || u.asyncNoop;\n return (oldElement, newElement, options) => Promise.all([\n oldAnimationFn(oldElement, options),\n newAnimationFn(newElement, options)\n ]);\n }\n }\n function findAnimationFn(object) {\n if (isNone(object)) {\n return undefined;\n }\n else if (u.isFunction(object)) {\n return object;\n }\n else if (u.isString(object)) {\n return findNamedAnimation(object);\n }\n else if (u.isOptions(object)) {\n return (element, options) => animateNow(element, object, options);\n }\n else {\n up.fail('Unknown animation %o', object);\n }\n }\n const swapElementsDirectly = up.mockable(function (oldElement, newElement) {\n oldElement.replaceWith(newElement);\n });\n function motionOptions(element, options, parserOptions) {\n options = u.options(options);\n let parser = new up.OptionsParser(element, options, parserOptions);\n parser.booleanOrString('animation');\n parser.booleanOrString('transition');\n parser.string('easing');\n parser.number('duration');\n return options;\n }\n function registerTransition(name, transition) {\n const fn = findTransitionFn(transition);\n fn.isDefault = up.framework.evaling;\n namedTransitions[name] = fn;\n }\n function registerAnimation(name, animation) {\n const fn = findAnimationFn(animation);\n fn.isDefault = up.framework.evaling;\n namedAnimations[name] = fn;\n }\n up.on('up:framework:boot', function () {\n if (!isEnabled()) {\n up.puts('up.motion', 'Animations are disabled');\n }\n });\n function isNone(animationOrTransition) {\n return !animationOrTransition || animationOrTransition === 'none';\n }\n function registerOpacityAnimation(name, from, to) {\n registerAnimation(name, function (element, options) {\n element.style.opacity = 0;\n e.setStyle(element, { opacity: from });\n return animateNow(element, { opacity: to }, options);\n });\n }\n registerOpacityAnimation('fade-in', 0, 1);\n registerOpacityAnimation('fade-out', 1, 0);\n function translateCSS(dx, dy) {\n return { transform: `translate(${dx}px, ${dy}px)` };\n }\n function noTranslateCSS() {\n return { transform: null };\n }\n function untranslatedBox(element) {\n e.setStyle(element, noTranslateCSS());\n return element.getBoundingClientRect();\n }\n function registerMoveAnimations(direction, boxToTransform) {\n const animationToName = `move-to-${direction}`;\n const animationFromName = `move-from-${direction}`;\n registerAnimation(animationToName, function (element, options) {\n const box = untranslatedBox(element);\n const transform = boxToTransform(box);\n return animateNow(element, transform, options);\n });\n registerAnimation(animationFromName, function (element, options) {\n const box = untranslatedBox(element);\n const transform = boxToTransform(box);\n e.setStyle(element, transform);\n return animateNow(element, noTranslateCSS(), options);\n });\n }\n registerMoveAnimations('top', function (box) {\n const travelDistance = box.top + box.height;\n return translateCSS(0, -travelDistance);\n });\n registerMoveAnimations('bottom', function (box) {\n const travelDistance = up.viewport.rootHeight() - box.top;\n return translateCSS(0, travelDistance);\n });\n registerMoveAnimations('left', function (box) {\n const travelDistance = box.left + box.width;\n return translateCSS(-travelDistance, 0);\n });\n registerMoveAnimations('right', function (box) {\n const travelDistance = up.viewport.rootWidth() - box.left;\n return translateCSS(travelDistance, 0);\n });\n registerTransition('cross-fade', ['fade-out', 'fade-in']);\n registerTransition('move-left', ['move-to-left', 'move-from-right']);\n registerTransition('move-right', ['move-to-right', 'move-from-left']);\n registerTransition('move-up', ['move-to-top', 'move-from-bottom']);\n registerTransition('move-down', ['move-to-bottom', 'move-from-top']);\n up.on('up:framework:reset', reset);\n return {\n morph,\n animate,\n finish,\n finishCount() { return motionController.finishCount; },\n transition: registerTransition,\n animation: registerAnimation,\n config,\n isEnabled,\n isNone,\n willAnimate,\n swapElementsDirectly,\n motionOptions,\n };\n})();\nup.transition = up.motion.transition;\nup.animation = up.motion.animation;\nup.morph = up.motion.morph;\nup.animate = up.motion.animate;\n\n\n/***/ }),\n/* 91 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(92);\nconst u = up.util;\nup.network = (function () {\n const config = new up.Config(() => ({\n concurrency: 6,\n wrapMethod: true,\n cacheSize: 70,\n cacheExpireAge: 15 * 1000,\n cacheEvictAge: 90 * 60 * 1000,\n badResponseTime: 400,\n fail(response) { return (response.status < 200 || response.status > 299) && response.status !== 304; },\n autoCache(request) { return request.isSafe(); },\n expireCache(request, _response) { return !request.isSafe(); },\n evictCache: false,\n progressBar: true,\n timeout: 90000,\n }));\n const queue = new up.Request.Queue();\n const cache = new up.Request.Cache();\n let progressBar = null;\n function reset() {\n abortRequests();\n queue.reset();\n cache.reset();\n progressBar?.destroy();\n progressBar = null;\n }\n function makeRequest(...args) {\n const options = parseRequestOptions(args);\n const request = new up.Request(options);\n processRequest(request);\n return request;\n }\n function parseRequestOptions(args) {\n const options = u.extractOptions(args);\n if (!options.url) {\n options.url = args[0];\n }\n up.migrate.handleRequestOptions?.(options);\n return options;\n }\n function processRequest(request) {\n useCachedRequest(request) || queueRequest(request);\n }\n function useCachedRequest(newRequest) {\n let cachedRequest;\n if (newRequest.willCache() && (cachedRequest = cache.get(newRequest))) {\n up.puts('up.request()', 'Re-using previous request to %s', newRequest.description);\n if (!newRequest.background) {\n queue.promoteToForeground(cachedRequest);\n }\n cache.track(cachedRequest, newRequest, { onIncompatible: processRequest });\n return true;\n }\n }\n function queueRequest(request) {\n handleCaching(request);\n queue.asap(request);\n return true;\n }\n function handleCaching(request) {\n if (request.willCache()) {\n cache.put(request);\n request.onLoading = () => cache.put(request);\n }\n u.always(request, function (responseOrError) {\n let expireCache = responseOrError.expireCache ?? request.expireCache ?? u.evalOption(config.expireCache, request, responseOrError);\n if (expireCache) {\n cache.expire(expireCache, { except: request });\n }\n let evictCache = responseOrError.evictCache ?? request.evictCache ?? u.evalOption(config.evictCache, request, responseOrError);\n if (evictCache) {\n cache.evict(evictCache, { except: request });\n }\n if (cache.get(request)) {\n cache.put(request);\n }\n if (!responseOrError.isCacheable?.()) {\n cache.evict(request);\n }\n });\n }\n function isBusy() {\n return queue.isBusy();\n }\n function loadPage(requestsAttrs) {\n new up.Request(requestsAttrs).loadPage();\n }\n function abortRequests(...args) {\n up.migrate.preprocessAbortArgs?.(args);\n queue.abort(...args);\n }\n function registerAliasForRedirect(request, response) {\n if (request.cache && response.url && request.url !== response.url) {\n const newRequest = u.variant(request, {\n method: response.method,\n url: response.url\n });\n cache.alias(request, newRequest);\n }\n }\n function isSafeMethod(method) {\n return u.contains(['GET', 'OPTIONS', 'HEAD'], u.normalizeMethod(method));\n }\n function onLate() {\n if (u.evalOption(config.progressBar)) {\n progressBar = new up.ProgressBar();\n }\n }\n function onRecover() {\n progressBar?.conclude();\n }\n up.on('up:network:late', onLate);\n up.on('up:network:recover', onRecover);\n up.on('up:framework:reset', reset);\n return {\n request: makeRequest,\n cache,\n isBusy,\n isSafeMethod,\n config,\n abort: abortRequests,\n registerAliasForRedirect,\n queue,\n loadPage,\n };\n})();\nup.request = up.network.request;\nup.cache = up.network.cache;\n\n\n/***/ }),\n/* 92 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 93 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(94);\nconst u = up.util;\nconst e = up.element;\nup.layer = (function () {\n const LAYER_CLASSES = [\n up.Layer.Root,\n up.Layer.Modal,\n up.Layer.Popup,\n up.Layer.Drawer,\n up.Layer.Cover\n ];\n const config = new up.Config(function () {\n const newConfig = {\n mode: 'modal',\n any: {\n mainTargets: [\n \"[up-main='']\",\n 'main',\n ':layer'\n ]\n },\n root: {\n mainTargets: ['[up-main~=root]'],\n history: true\n },\n overlay: {\n mainTargets: ['[up-main~=overlay]'],\n openAnimation: 'fade-in',\n closeAnimation: 'fade-out',\n dismissLabel: '\u00D7',\n dismissAriaLabel: 'Dismiss dialog',\n dismissable: true,\n history: 'auto'\n },\n cover: {\n mainTargets: ['[up-main~=cover]']\n },\n drawer: {\n mainTargets: ['[up-main~=drawer]'],\n backdrop: true,\n position: 'left',\n size: 'medium',\n openAnimation(layer) {\n switch (layer.position) {\n case 'left': return 'move-from-left';\n case 'right': return 'move-from-right';\n }\n },\n closeAnimation(layer) {\n switch (layer.position) {\n case 'left': return 'move-to-left';\n case 'right': return 'move-to-right';\n }\n }\n },\n modal: {\n mainTargets: ['[up-main~=modal]'],\n backdrop: true,\n size: 'medium'\n },\n popup: {\n mainTargets: ['[up-main~=popup]'],\n position: 'bottom',\n size: 'medium',\n align: 'left',\n dismissable: 'outside key'\n },\n foreignOverlaySelectors: ['dialog']\n };\n for (let Class of LAYER_CLASSES) {\n newConfig[Class.mode].Class = Class;\n }\n return newConfig;\n });\n let stack = null;\n let handlers = [];\n function mainTargets(mode) {\n return u.flatMap(modeConfigs(mode), 'mainTargets');\n }\n function modeConfigs(mode) {\n if (mode === 'root') {\n return [config.root, config.any];\n }\n else {\n return [config[mode], config.overlay, config.any];\n }\n }\n function normalizeOptions(options) {\n up.migrate.handleLayerOptions?.(options);\n if (u.isGiven(options.layer)) {\n let match = String(options.layer).match(/^(new|shatter|swap)( (\\w+))?/);\n if (match) {\n options.layer = 'new';\n const openMethod = match[1];\n const shorthandMode = match[3];\n options.mode ||= shorthandMode || config.mode;\n if (openMethod === 'swap') {\n if (up.layer.isOverlay()) {\n options.baseLayer = 'parent';\n }\n }\n else if (openMethod === 'shatter') {\n options.baseLayer = 'root';\n }\n }\n }\n else {\n if (options.mode) {\n options.layer = 'new';\n }\n else if (u.isElementish(options.target)) {\n options.layer = stack.get(options.target, { normalizeLayerOptions: false });\n }\n else if (options.origin) {\n options.layer = 'origin';\n }\n else {\n options.layer = 'current';\n }\n }\n if (!options.context) {\n options.context = {};\n }\n options.baseLayer = stack.get('current', { ...options, normalizeLayerOptions: false });\n }\n function build(options, beforeNew) {\n const { mode } = options;\n const { Class } = config[mode];\n const configs = u.reverse(modeConfigs(mode));\n let handleDeprecatedConfig = up.migrate.handleLayerConfig;\n if (handleDeprecatedConfig) {\n configs.forEach(handleDeprecatedConfig);\n }\n options.openAnimation ??= u.pluckKey(options, 'animation');\n options = u.mergeDefined(...configs, { mode, stack }, options);\n if (beforeNew) {\n options = beforeNew(options);\n }\n return new Class(options);\n }\n function openCallbackAttr(link, attr) {\n return e.callbackAttr(link, attr, { exposedKeys: ['layer'] });\n }\n function closeCallbackAttr(link, attr) {\n return e.callbackAttr(link, attr, { exposedKeys: ['layer', 'value', 'response'] });\n }\n function reset() {\n stack.reset();\n handlers = u.filter(handlers, 'isDefault');\n }\n async function open(options) {\n options = u.options(options, {\n layer: 'new',\n defaultToEmptyContent: true,\n navigate: true\n });\n let result = await up.render(options);\n return result.layer;\n }\n function ask(options) {\n return new Promise(function (resolve, reject) {\n options = {\n ...options,\n onAccepted: (event) => resolve(event.value),\n onDismissed: (event) => reject(event.value)\n };\n open(options);\n });\n }\n function anySelector() {\n return u.map(LAYER_CLASSES, Class => Class.selector()).join();\n }\n function optionToString(option) {\n if (u.isString(option)) {\n return `layer \"${option}\"`;\n }\n else {\n return option.toString();\n }\n }\n function isWithinForeignOverlay(element) {\n let selector = config.selector('foreignOverlaySelectors');\n return !!(selector && element.closest(selector));\n }\n up.on('up:fragment:destroyed', function () {\n stack.sync();\n });\n up.on('up:framework:evaled', function () {\n stack = new up.LayerStack();\n });\n up.on('up:framework:reset', reset);\n const api = {\n config,\n mainTargets,\n open,\n build,\n ask,\n normalizeOptions,\n openCallbackAttr,\n closeCallbackAttr,\n anySelector,\n optionToString,\n get stack() { return stack.layers; },\n isWithinForeignOverlay\n };\n u.delegate(api, [\n 'get',\n 'getAll',\n 'root',\n 'overlays',\n 'current',\n 'front',\n 'sync',\n 'count',\n 'dismissOverlays'\n ], () => stack);\n u.delegate(api, [\n 'accept',\n 'dismiss',\n 'isRoot',\n 'isOverlay',\n 'isFront',\n 'on',\n 'off',\n 'emit',\n 'parent',\n 'history',\n 'location',\n 'mode',\n 'context',\n 'element',\n 'contains',\n 'size',\n 'affix'\n ], () => stack.current);\n return api;\n})();\n\n\n/***/ }),\n/* 94 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 95 */\n/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {\n\n__webpack_require__(96);\nup.link = (function () {\n const u = up.util;\n const e = up.element;\n const linkPreloader = new up.LinkPreloader();\n let lastMousedownTarget = null;\n const LINKS_WITH_LOCAL_HTML = ['a[up-content]', 'a[up-fragment]', 'a[up-document]'];\n const LINKS_WITH_REMOTE_HTML = ['a[href]', '[up-href]'];\n const ATTRIBUTES_SUGGESTING_FOLLOW = ['[up-follow]', '[up-target]', '[up-layer]', '[up-transition]', '[up-preload]', '[up-instant]', '[up-href]'];\n function combineFollowableSelectors(elementSelectors, attributeSelectors) {\n return u.flatMap(elementSelectors, elementSelector => attributeSelectors.map(attrSelector => elementSelector + attrSelector));\n }\n const config = new up.Config(() => ({\n followSelectors: combineFollowableSelectors(LINKS_WITH_REMOTE_HTML, ATTRIBUTES_SUGGESTING_FOLLOW).concat(LINKS_WITH_LOCAL_HTML),\n noFollowSelectors: ['[up-follow=false]', 'a[download]', 'a[target]', 'a[href^=\"#\"]:not([up-content]):not([up-fragment]):not([up-document])', 'a[href^=\"javascript:\"]', 'a[href^=\"mailto:\"]', e.crossOriginSelector('href'), e.crossOriginSelector('up-href')],\n instantSelectors: ['[up-instant]'],\n noInstantSelectors: ['[up-instant=false]', '[onclick]'],\n preloadSelectors: combineFollowableSelectors(LINKS_WITH_REMOTE_HTML, ['[up-preload]']),\n noPreloadSelectors: ['[up-preload=false]'],\n clickableSelectors: LINKS_WITH_LOCAL_HTML.concat(['[up-emit]', '[up-accept]', '[up-dismiss]', '[up-clickable]']),\n preloadDelay: 90,\n }));\n function isPreloadDisabled(link) {\n return !up.browser.canPushState() || !isFollowable(link) || !willCache(link);\n }\n function willCache(link) {\n const options = parseRequestOptions(link);\n if (options.url) {\n if (options.cache == null) {\n options.cache = 'auto';\n }\n options.basic = true;\n const request = new up.Request(options);\n return request.willCache();\n }\n }\n function reset() {\n lastMousedownTarget = null;\n linkPreloader.reset();\n }\n const follow = up.mockable(function (link, options) {\n return up.render(followOptions(link, options));\n });\n function parseRequestOptions(link, options, parserOptions) {\n options = u.options(options);\n const parser = new up.OptionsParser(link, options, { ...parserOptions, fail: false });\n options.url = followURL(link, options);\n options.method = followMethod(link, options);\n parser.json('headers');\n parser.json('params');\n parser.booleanOrString('cache');\n parser.booleanOrString('expireCache');\n parser.booleanOrString('evictCache');\n parser.booleanOrString('revalidate');\n parser.booleanOrString('abort');\n parser.boolean('abortable');\n parser.boolean('background');\n parser.string('contentType');\n parser.number('badResponseTime');\n parser.number('timeout');\n return options;\n }\n function followOptions(link, options, parserOptions) {\n link = up.fragment.get(link);\n options = u.options(options);\n const parser = new up.OptionsParser(link, options, { fail: true, ...parserOptions });\n parser.include(parseRequestOptions);\n parser.boolean('feedback');\n options.origin ||= link;\n parser.boolean('fail');\n parser.boolean('navigate', { default: true });\n parser.string('confirm', { attr: ['up-confirm', 'data-confirm'] });\n parser.string('target');\n parser.booleanOrString('fallback');\n parser.string('match');\n parser.string('content');\n parser.string('fragment');\n parser.string('document');\n parser.boolean('useKeep');\n parser.boolean('useHungry');\n parser.callback('onLoaded');\n parser.callback('onRendered', { mainKey: 'result' });\n parser.callback('onFinished', { mainKey: 'result' });\n parser.callback('onOffline', { mainKey: 'error' });\n parser.callback('onError', { mainKey: 'error' });\n parser.boolean('peel');\n parser.string('layer');\n parser.string('baseLayer');\n parser.json('context');\n parser.string('mode');\n parser.string('align');\n parser.string('position');\n parser.string('class');\n parser.string('size');\n parser.booleanOrString('dismissable');\n parser.parse(up.layer.openCallbackAttr, 'onOpened');\n parser.parse(up.layer.closeCallbackAttr, 'onAccepted');\n parser.parse(up.layer.closeCallbackAttr, 'onDismissed');\n parser.string('acceptEvent');\n parser.string('dismissEvent');\n parser.string('acceptLocation');\n parser.string('dismissLocation');\n parser.booleanOrString('history');\n parser.booleanOrString('focus');\n parser.boolean('saveScroll');\n parser.boolean('saveFocus');\n parser.booleanOrString('scroll');\n parser.boolean('revealTop');\n parser.number('revealMax');\n parser.number('revealPadding');\n parser.number('revealSnap');\n parser.string('scrollBehavior');\n parser.booleanOrString('history');\n parser.booleanOrString('location');\n parser.booleanOrString('title');\n parser.boolean('metaTags');\n parser.include(up.motion.motionOptions);\n if (!options.guardEvent) {\n options.guardEvent = up.event.build('up:link:follow', { log: 'Following link' });\n }\n return options;\n }\n function preload(link, options) {\n link = up.fragment.get(link);\n let issue = preloadIssue(link);\n if (issue) {\n return Promise.reject(new up.Error(issue));\n }\n const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });\n return follow(link, {\n abortable: false,\n ...options,\n guardEvent,\n preload: true\n });\n }\n function preloadIssue(link) {\n if (!isSafe(link)) {\n return 'Will not preload an unsafe link';\n }\n }\n function followMethod(link, options = {}) {\n return u.normalizeMethod(options.method || link.getAttribute('up-method') || link.getAttribute('data-method'));\n }\n function followURL(link, options = {}) {\n const url = options.url || link.getAttribute('up-href') || link.getAttribute('href');\n if (url !== '#') {\n return url;\n }\n }\n function isFollowable(link) {\n link = up.fragment.get(link);\n return config.matches(link, 'followSelectors');\n }\n function makeFollowable(link) {\n if (!isFollowable(link)) {\n link.setAttribute('up-follow', '');\n }\n }\n function makeClickable(link) {\n if (link.matches('a[href], button')) {\n return;\n }\n e.setMissingAttrs(link, {\n tabindex: '0',\n role: 'link',\n 'up-clickable': ''\n });\n link.addEventListener('keydown', function (event) {\n if ((event.key === 'Enter') || (event.key === 'Space')) {\n return forkEventAsUpClick(event);\n }\n });\n }\n up.macro(config.selectorFn('clickableSelectors'), makeClickable);\n function shouldFollowEvent(event, link) {\n if (event.defaultPrevented) {\n return false;\n }\n const betterTargetSelector = `a, [up-href], ${up.form.fieldSelector()}`;\n const betterTarget = event.target.closest(betterTargetSelector);\n return !betterTarget || (betterTarget === link);\n }\n function isInstant(linkOrDescendant) {\n const element = linkOrDescendant.closest(config.selector('instantSelectors'));\n return element && !isInstantDisabled(element);\n }\n function isInstantDisabled(link) {\n return config.matches(link, 'noInstantSelectors') || config.matches(link, 'noFollowSelectors');\n }\n function convertClicks(layer) {\n layer.on('click', function (event, element) {\n if (!up.event.isUnmodified(event)) {\n return;\n }\n if (isInstant(element) && lastMousedownTarget) {\n up.event.halt(event);\n }\n else if (layer.wasHitByMouseEvent(event) && !didUserDragAway(event)) {\n forkEventAsUpClick(event);\n }\n return lastMousedownTarget = null;\n });\n layer.on('mousedown', function (event, element) {\n if (!up.event.isUnmodified(event)) {\n return;\n }\n lastMousedownTarget = event.target;\n if (isInstant(element)) {\n forkEventAsUpClick(event);\n }\n });\n }\n function didUserDragAway(clickEvent) {\n return lastMousedownTarget && (lastMousedownTarget !== clickEvent.target);\n }\n function forkEventAsUpClick(originalEvent) {\n let forwardedProps = ['clientX', 'clientY', 'button', ...up.event.keyModifiers];\n const newEvent = up.event.fork(originalEvent, 'up:click', forwardedProps);\n up.emit(originalEvent.target, newEvent, { log: false });\n }\n function isSafe(link) {\n const method = followMethod(link);\n return up.network.isSafeMethod(method);\n }\n up.on('up:click', config.selectorFn('followSelectors'), function (event, link) {\n if (shouldFollowEvent(event, link)) {\n up.event.halt(event, { log: true });\n up.focus(link, { preventScroll: true });\n up.error.muteUncriticalRejection(follow(link));\n }\n });\n up.macro('[up-expand]', function (area) {\n const selector = area.getAttribute('up-expand') || 'a, [up-href]';\n let childLink = e.get(area, selector);\n if (childLink) {\n const areaAttrs = e.upAttrs(childLink);\n areaAttrs['up-href'] ||= childLink.getAttribute('href');\n e.setMissingAttrs(area, areaAttrs);\n const areaClasses = e.upClasses(childLink);\n area.classList.add(...areaClasses);\n makeFollowable(area);\n }\n });\n up.compiler(config.selectorFn('preloadSelectors'), function (link) {\n if (!isPreloadDisabled(link)) {\n linkPreloader.watchLink(link);\n }\n });\n up.on('up:framework:reset', reset);\n return {\n follow,\n followOptions,\n preload,\n makeFollowable,\n makeClickable,\n isSafe,\n isFollowable,\n shouldFollowEvent,\n followMethod,\n convertClicks,\n config,\n combineFollowableSelectors,\n preloadIssue,\n };\n})();\nup.follow = up.link.follow;\n\n\n/***/ }),\n/* 96 */\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n/***/ }),\n/* 97 */\n/***/ (() => {\n\nup.form = (function () {\n const u = up.util;\n const e = up.element;\n const ATTRIBUTES_SUGGESTING_SUBMIT = ['[up-submit]', '[up-target]', '[up-layer]', '[up-transition]'];\n const config = new up.Config(() => ({\n groupSelectors: ['[up-form-group]', 'fieldset', 'label', 'form'],\n fieldSelectors: ['select', 'input:not([type=submit]):not([type=image])', 'button[type]:not([type=submit])', 'textarea'],\n submitSelectors: up.link.combineFollowableSelectors(['form'], ATTRIBUTES_SUGGESTING_SUBMIT),\n noSubmitSelectors: ['[up-submit=false]', '[target]', e.crossOriginSelector('action')],\n submitButtonSelectors: ['input[type=submit]', 'input[type=image]', 'button[type=submit]', 'button:not([type])'],\n watchInputEvents: ['input', 'change'],\n watchInputDelay: 0,\n watchChangeEvents: ['change'],\n }));\n function fieldSelector(suffix = '') {\n return config.fieldSelectors.map(field => field + suffix).join();\n }\n function isField(element) {\n return element.matches(fieldSelector());\n }\n function findFields(root) {\n root = e.get(root);\n let fields = e.subtree(root, fieldSelector());\n if (root.matches('form[id]')) {\n const outsideFieldSelector = fieldSelector(e.attrSelector('form', root.getAttribute('id')));\n const outsideFields = up.fragment.all(outsideFieldSelector, { layer: root });\n fields.push(...outsideFields);\n fields = u.uniq(fields);\n }\n return fields;\n }\n function findSubmitButtons(root) {\n return e.subtree(root, submitButtonSelector());\n }\n function submittingButton(form) {\n const selector = submitButtonSelector();\n const focusedElement = document.activeElement;\n if (focusedElement && focusedElement.form === form) {\n if (focusedElement.matches(selector)) {\n return focusedElement;\n }\n }\n return e.get(form, selector);\n }\n function submitButtonSelector() {\n return config.selector('submitButtonSelectors');\n }\n const submit = up.mockable((form, options) => {\n return up.render(submitOptions(form, options));\n });\n function submitOptions(form, options, parserOptions) {\n form = getForm(form);\n options = u.options(options);\n let parser = new up.OptionsParser(form, options, parserOptions);\n parser.include(destinationOptions);\n parser.string('failTarget', { default: up.fragment.tryToTarget(form) });\n parser.booleanOrString('disable');\n options.guardEvent ||= up.event.build('up:form:submit', {\n submitButton: options.submitButton,\n log: 'Submitting form',\n params: options.params\n });\n options.origin ||= up.viewport.focusedElementWithin(form) || options.submitButton || form;\n parser.include(up.link.followOptions);\n return options;\n }\n function watchOptions(field, options, parserOptions = {}) {\n options = u.options(options);\n let parser = new up.OptionsParser(field, options, { ...parserOptions, closest: true, attrPrefix: 'up-watch-' });\n parser.boolean('feedback');\n parser.booleanOrString('disable');\n parser.string('event');\n parser.number('delay');\n let config = up.form.config;\n if (options.event === 'input') {\n options.event = u.evalOption(config.watchInputEvents, field);\n options.delay ??= config.watchInputDelay;\n }\n else if (options.event === 'change') {\n options.event = u.evalOption(config.watchChangeEvents, field);\n }\n options.origin ||= field;\n return options;\n }\n function disableContainer(container) {\n let focusedElement = document.activeElement;\n let focusFallback;\n let controls = [...findFields(container), ...findSubmitButtons(container)];\n for (let control of controls) {\n if (control === focusedElement) {\n focusFallback = findGroup(focusedElement);\n }\n raiseDisableStack(control);\n }\n if (focusFallback) {\n up.focus(focusFallback, { force: true, preventScroll: true });\n }\n return function () {\n controls.forEach(lowerDisableStack);\n };\n }\n function raiseDisableStack(control) {\n if (!control.upDisableCount) {\n control.upDisableCount ||= 0;\n control.upOriginalDisabled = control.disabled;\n }\n control.upDisableCount++;\n control.disabled = true;\n }\n function lowerDisableStack(control) {\n if (control.upDisableCount) {\n if (!control.disabled) {\n control.upDisableCount = 0;\n }\n else {\n control.upDisableCount--;\n if (!control.upDisableCount) {\n control.disabled = control.upOriginalDisabled;\n }\n }\n }\n }\n function disableWhile(promise, options) {\n let undoDisable = handleDisableOption(options);\n u.always(promise, undoDisable);\n }\n function handleDisableOption({ disable, origin }) {\n if (!disable)\n return u.noop;\n let missingOption = (key) => { up.fail(\"Cannot process { disable: '%s' } option without { %s }\", disable, key); };\n let getOrigin = () => origin || missingOption('origin');\n let getOriginForm = () => getScope(getOrigin());\n let containers;\n if (disable === true) {\n containers = [getOriginForm()];\n }\n else if (u.isString(disable)) {\n containers = up.fragment.subtree(getOriginForm(), disable, { origin });\n }\n return u.sequence(containers.map(disableContainer));\n }\n function destinationOptions(form, options, parserOptions) {\n options = u.options(options);\n form = getForm(form);\n const parser = new up.OptionsParser(form, options, parserOptions);\n parser.string('contentType', { attr: 'enctype' });\n parser.json('headers');\n const params = up.Params.fromForm(form);\n const submitButton = submittingButton(form);\n if (submitButton) {\n options.submitButton = submitButton;\n params.addField(submitButton);\n options.method ||= submitButton.getAttribute('formmethod');\n options.url ||= submitButton.getAttribute('formaction');\n }\n params.addAll(options.params);\n options.params = params;\n parser.string('url', { attr: 'action', default: up.fragment.source(form) });\n parser.string('method', {\n attr: ['up-method', 'data-method', 'method'],\n default: 'GET',\n normalize: u.normalizeMethod\n });\n if (options.method === 'GET') {\n options.url = up.Params.stripURL(options.url);\n }\n return options;\n }\n up.on('up:click', submitButtonSelector, function (event, button) {\n const form = getForm(button);\n if (form && isSubmittable(form)) {\n button.focus();\n }\n });\n function watch(root, ...args) {\n root = up.element.get(root);\n const callback = u.extractCallback(args) || watchCallbackFromElement(root) || up.fail('No callback given for up.watch()');\n let options = u.extractOptions(args);\n const watcher = new up.FieldWatcher(root, options, callback);\n watcher.start();\n return () => watcher.stop();\n }\n function watchCallbackFromElement(element) {\n let rawCallback = element.getAttribute('up-watch');\n if (rawCallback) {\n return up.NonceableCallback.fromString(rawCallback).toFunction('value', 'name').bind(element);\n }\n }\n function autosubmit(target, options = {}) {\n const onChange = (_diff, renderOptions) => submit(target, renderOptions);\n return watch(target, { options, batch: true }, onChange);\n }\n function getGroupSelectors() {\n return up.migrate.migratedFormGroupSelectors?.() || config.groupSelectors;\n }\n function findGroup(field) {\n return findGroupSolution(field).element;\n }\n function findGroupSolution(field) {\n return u.findResult(getGroupSelectors(), function (groupSelector) {\n let group = field.closest(groupSelector);\n if (group) {\n let goodDerivedGroupTarget = up.fragment.tryToTarget(group);\n let goodDerivedFieldTarget = up.fragment.tryToTarget(field);\n let groupHasFieldTarget = goodDerivedFieldTarget && (group !== field) && `${groupSelector}:has(${goodDerivedFieldTarget})`;\n let target = goodDerivedGroupTarget || groupHasFieldTarget;\n if (target) {\n return {\n target,\n element: group,\n origin: field\n };\n }\n }\n });\n }\n function validate(...args) {\n let options = parseValidateArgs(...args);\n let validator = up.FormValidator.forElement(options.origin);\n return validator.validate(options);\n }\n function parseValidateArgs(originOrTarget, ...args) {\n const options = u.extractOptions(args);\n if (options.origin) {\n options.target ||= up.fragment.toTarget(originOrTarget);\n }\n else {\n options.origin ||= up.fragment.get(originOrTarget);\n }\n return options;\n }\n function switcherValues(field) {\n let value;\n let meta;\n if (field.matches('input[type=checkbox]')) {\n if (field.checked) {\n value = field.value;\n meta = ':checked';\n }\n else {\n meta = ':unchecked';\n }\n }\n else if (field.matches('input[type=radio]')) {\n const form = getScope(field);\n const groupName = field.getAttribute('name');\n const checkedButton = form.querySelector(`input[type=radio]${e.attrSelector('name', groupName)}:checked`);\n if (checkedButton) {\n meta = ':checked';\n value = checkedButton.value;\n }\n else {\n meta = ':unchecked';\n }\n }\n else {\n value = field.value;\n }\n const values = [];\n if (u.isPresent(value)) {\n values.push(value);\n values.push(':present');\n }\n else {\n values.push(':blank');\n }\n if (u.isPresent(meta)) {\n values.push(meta);\n }\n return values;\n }\n function switchTargets(switcher, options = {}) {\n const targetSelector = options.target || options.target || switcher.getAttribute('up-switch');\n const form = getScope(switcher);\n targetSelector || up.fail(\"No switch target given for %o\", switcher);\n const fieldValues = switcherValues(switcher);\n for (let target of up.fragment.all(form, targetSelector)) {\n switchTarget(target, fieldValues);\n }\n }\n const switchTarget = up.mockable(function (target, fieldValues) {\n let show;\n fieldValues ||= switcherValues(findSwitcherForTarget(target));\n let hideValues = target.getAttribute('up-hide-for');\n if (hideValues) {\n hideValues = parseSwitchTokens(hideValues);\n show = u.intersect(fieldValues, hideValues).length === 0;\n }\n else {\n let showValues = target.getAttribute('up-show-for');\n showValues = showValues ? parseSwitchTokens(showValues) : [':present', ':checked'];\n show = u.intersect(fieldValues, showValues).length > 0;\n }\n e.toggle(target, show);\n target.classList.add('up-switched');\n });\n function parseSwitchTokens(str) {\n return u.parseTokens(str, { json: true });\n }\n function findSwitcherForTarget(target) {\n const form = getScope(target);\n const switchers = form.querySelectorAll('[up-switch]');\n const switcher = u.find(switchers, function (switcher) {\n const targetSelector = switcher.getAttribute('up-switch');\n return target.matches(targetSelector);\n });\n return switcher || up.fail('Could not find [up-switch] field for %o', target);\n }\n function getForm(elementOrSelector, options = {}) {\n const element = up.fragment.get(elementOrSelector, options);\n return element.form || element.closest('form');\n }\n function getScope(element, options) {\n return getForm(element, options) || up.layer.get(element).element;\n }\n function focusedField() {\n return u.presence(document.activeElement, isField);\n }\n function isSubmittable(form) {\n form = up.fragment.get(form);\n return config.matches(form, 'submitSelectors');\n }\n up.on('submit', config.selectorFn('submitSelectors'), function (event, form) {\n if (event.defaultPrevented)\n return;\n up.event.halt(event, { log: true });\n up.error.muteUncriticalRejection(submit(form));\n });\n up.compiler(validatingFieldSelector, function (fieldOrForm) {\n let validator = up.FormValidator.forElement(fieldOrForm);\n validator.watchContainer(fieldOrForm);\n });\n function validatingFieldSelector() {\n return config.fieldSelectors.map((selector) => `${selector}[up-validate], [up-validate] ${selector}`).join(', ');\n }\n up.compiler('[up-switch]', (switcher) => {\n switchTargets(switcher);\n });\n up.on('change', '[up-switch]', (_event, switcher) => {\n switchTargets(switcher);\n });\n up.compiler('[up-show-for]:not(.up-switched), [up-hide-for]:not(.up-switched)', (element) => {\n switchTarget(element);\n });\n up.compiler('[up-watch]', (formOrField) => watch(formOrField));\n up.compiler('[up-autosubmit]', (formOrField) => autosubmit(formOrField));\n return {\n config,\n submit,\n submitOptions,\n destinationOptions,\n watchOptions,\n isSubmittable,\n watch,\n validate,\n autosubmit,\n fieldSelector,\n fields: findFields,\n isField,\n submitButtons: findSubmitButtons,\n focusedField,\n switchTarget,\n disableWhile,\n disable: disableContainer,\n group: findGroup,\n groupSolution: findGroupSolution,\n groupSelectors: getGroupSelectors,\n get: getForm,\n getScope,\n };\n})();\nup.submit = up.form.submit;\nup.watch = up.form.watch;\nup.autosubmit = up.form.autosubmit;\nup.validate = up.form.validate;\n\n\n/***/ }),\n/* 98 */\n/***/ (() => {\n\nup.feedback = (function () {\n const u = up.util;\n const e = up.element;\n const config = new up.Config(() => ({\n currentClasses: ['up-current'],\n navSelectors: ['[up-nav]', 'nav'],\n }));\n function reset() {\n up.layer.root.feedbackLocation = null;\n }\n const CLASS_ACTIVE = 'up-active';\n const CLASS_LOADING = 'up-loading';\n const SELECTOR_LINK = 'a, [up-href]';\n function navSelector() {\n return config.selector('navSelectors');\n }\n function normalizeURL(url) {\n if (url) {\n return u.normalizeURL(url, { trailingSlash: false, hash: false });\n }\n }\n function linkURLs(link) {\n return link.upFeedbackURLs ||= new up.LinkFeedbackURLs(link);\n }\n function updateFragment(fragment) {\n const layerOption = { layer: up.layer.get(fragment) };\n if (up.fragment.closest(fragment, navSelector(), layerOption)) {\n const links = up.fragment.subtree(fragment, SELECTOR_LINK, layerOption);\n updateLinks(links, layerOption);\n }\n else {\n updateLinksWithinNavs(fragment, layerOption);\n }\n }\n function updateLinksWithinNavs(fragment, options) {\n const navs = up.fragment.subtree(fragment, navSelector(), options);\n const links = u.flatMap(navs, nav => e.subtree(nav, SELECTOR_LINK));\n updateLinks(links, options);\n }\n function getNormalizedLayerLocation(layer) {\n return layer.feedbackLocation || normalizeURL(layer.location);\n }\n function updateLinks(links, options = {}) {\n if (!links.length) {\n return;\n }\n const layer = options.layer || up.layer.get(links[0]);\n let layerLocation = getNormalizedLayerLocation(layer);\n if (layerLocation) {\n for (let link of links) {\n const isCurrent = linkURLs(link).isCurrent(layerLocation);\n for (let currentClass of config.currentClasses) {\n link.classList.toggle(currentClass, isCurrent);\n }\n e.toggleAttr(link, 'aria-current', 'page', isCurrent);\n }\n }\n }\n function findActivatableArea(element) {\n return e.ancestor(element, SELECTOR_LINK) || element;\n }\n function showAroundRequest(request, options) {\n if (!options.feedback) {\n return;\n }\n let clean = (fn) => u.always(request, fn);\n let activeElement = getActiveElementFromRenderOptions(request);\n if (activeElement) {\n clean(e.addTemporaryClass(activeElement, CLASS_ACTIVE));\n }\n for (let fragment of request.fragments) {\n clean(e.addTemporaryClass(fragment, CLASS_LOADING));\n }\n }\n function getActiveElementFromRenderOptions(request) {\n let activeElement = request.origin;\n if (activeElement) {\n return findActivatableArea(activeElement);\n }\n }\n function updateLayerIfLocationChanged(layer) {\n const processedLocation = layer.feedbackLocation;\n const layerLocation = getNormalizedLayerLocation(layer.location);\n if (!processedLocation || (processedLocation !== layerLocation)) {\n layer.feedbackLocation = layerLocation;\n updateLinksWithinNavs(layer.element, { layer });\n }\n }\n function onBrowserLocationChanged() {\n const frontLayer = up.layer.front;\n if (frontLayer.showsLiveHistory()) {\n updateLayerIfLocationChanged(frontLayer);\n }\n }\n up.on('up:location:changed', (_event) => {\n onBrowserLocationChanged();\n });\n up.on('up:fragment:compile', (_event, newFragment) => {\n updateFragment(newFragment);\n });\n up.on('up:layer:location:changed', (event) => {\n updateLayerIfLocationChanged(event.layer);\n });\n up.on('up:framework:reset', reset);\n return {\n config,\n showAroundRequest,\n normalizeURL,\n };\n})();\n\n\n/***/ }),\n/* 99 */\n/***/ (() => {\n\nup.radio = (function () {\n const e = up.element;\n const config = new up.Config(() => ({\n hungrySelectors: ['[up-hungry]'],\n pollInterval: 30000,\n }));\n function hungrySteps(renderOptions) {\n let { useHungry, origin, layer: renderLayer } = renderOptions;\n let steps = { current: [], other: [] };\n if (!useHungry)\n return steps;\n let hungrySelector = config.selector('hungrySelectors');\n const layerPreference = [renderLayer, ...renderLayer.ancestors, ...renderLayer.descendants];\n for (let elementLayer of layerPreference) {\n let hungries = up.fragment.all(elementLayer.element, hungrySelector, { layer: elementLayer });\n for (let element of hungries) {\n let selector = up.fragment.tryToTarget(element, { origin });\n if (!selector) {\n up.warn('[up-hungry]', 'Ignoring untargetable fragment %o', element);\n continue;\n }\n let ifLayer = e.attr(element, 'up-if-layer');\n let applicableLayers = ifLayer ? up.layer.getAll(ifLayer, { baseLayer: elementLayer }) : [elementLayer];\n let motionOptions = up.motion.motionOptions(element);\n let selectEvent = up.event.build('up:fragment:hungry', { log: false });\n let selectCallback = e.callbackAttr(element, 'up-on-hungry', { exposedKeys: ['newFragment', 'renderOptions'] });\n let step = {\n selector,\n oldElement: element,\n layer: elementLayer,\n origin,\n ...motionOptions,\n placement: 'swap',\n useKeep: true,\n maybe: true,\n selectEvent,\n selectCallback,\n originalRenderOptions: renderOptions,\n };\n if (applicableLayers.includes(renderLayer)) {\n let list = renderLayer === elementLayer ? steps.current : steps.other;\n list.push(step);\n }\n }\n }\n steps.other = up.fragment.compressNestedSteps(steps.other);\n return steps;\n }\n function startPolling(fragment, options = {}) {\n up.FragmentPolling.forFragment(fragment).forceStart(options);\n }\n function stopPolling(element) {\n up.FragmentPolling.forFragment(element).forceStop();\n }\n function pollOptions(fragment, options = {}) {\n const parser = new up.OptionsParser(fragment, options);\n parser.number('interval', { default: config.pollInterval });\n parser.string('ifLayer', { default: 'front' });\n return options;\n }\n up.compiler('[up-poll]:not([up-poll=false])', function (fragment) {\n up.FragmentPolling.forFragment(fragment).onPollAttributeObserved();\n });\n up.macro('[up-flashes]', function (fragment) {\n e.setMissingAttrs(fragment, {\n 'up-hungry': '',\n 'up-if-layer': 'subtree',\n 'up-keep': '',\n 'role': 'alert',\n });\n fragment.addEventListener('up:fragment:keep', function (event) {\n if (!e.isEmpty(event.newFragment))\n event.preventDefault();\n });\n });\n return {\n config,\n hungrySteps,\n startPolling,\n stopPolling,\n pollOptions,\n };\n})();\n\n\n/***/ }),\n/* 100 */\n/***/ (() => {\n\n(function () {\n const e = up.element;\n function isRails() {\n return window.Rails ||\n window.jQuery?.rails;\n }\n for (let feature of ['method', 'confirm']) {\n const upAttribute = `up-${feature}`;\n const dataAttribute = `data-${feature}`;\n up.macro(`a[${dataAttribute}]`, function (link) {\n if (isRails() && up.link.isFollowable(link)) {\n e.setMissingAttr(link, upAttribute, link.getAttribute(dataAttribute));\n link.removeAttribute(dataAttribute);\n }\n });\n }\n})();\n\n\n/***/ })\n/******/ \t]);\n/************************************************************************/\n/******/ \t// The module cache\n/******/ \tvar __webpack_module_cache__ = {};\n/******/ \t\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/ \t\t// Check if module is in cache\n/******/ \t\tvar cachedModule = __webpack_module_cache__[moduleId];\n/******/ \t\tif (cachedModule !== undefined) {\n/******/ \t\t\treturn cachedModule.exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = __webpack_module_cache__[moduleId] = {\n/******/ \t\t\t// no module.id needed\n/******/ \t\t\t// no module.loaded needed\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/ \t\n/******/ \t\t// Execute the module function\n/******/ \t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n/******/ \t\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/make namespace object */\n/******/ \t(() => {\n/******/ \t\t// define __esModule on exports\n/******/ \t\t__webpack_require__.r = (exports) => {\n/******/ \t\t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t\t}\n/******/ \t\t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/************************************************************************/\nvar __webpack_exports__ = {};\n// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.\n(() => {\n__webpack_require__(1);\n__webpack_require__(2);\n__webpack_require__(3);\n__webpack_require__(4);\n__webpack_require__(5);\n__webpack_require__(6);\n__webpack_require__(7);\n__webpack_require__(9);\n__webpack_require__(10);\n__webpack_require__(11);\n__webpack_require__(12);\n__webpack_require__(13);\n__webpack_require__(14);\n__webpack_require__(15);\n__webpack_require__(16);\n__webpack_require__(17);\n__webpack_require__(18);\n__webpack_require__(19);\n__webpack_require__(20);\n__webpack_require__(21);\n__webpack_require__(22);\n__webpack_require__(23);\n__webpack_require__(24);\n__webpack_require__(25);\n__webpack_require__(26);\n__webpack_require__(27);\n__webpack_require__(28);\n__webpack_require__(29);\n__webpack_require__(30);\n__webpack_require__(31);\n__webpack_require__(32);\n__webpack_require__(33);\n__webpack_require__(34);\n__webpack_require__(35);\n__webpack_require__(36);\n__webpack_require__(37);\n__webpack_require__(38);\n__webpack_require__(39);\n__webpack_require__(40);\n__webpack_require__(41);\n__webpack_require__(42);\n__webpack_require__(43);\n__webpack_require__(44);\n__webpack_require__(45);\n__webpack_require__(46);\n__webpack_require__(47);\n__webpack_require__(48);\n__webpack_require__(49);\n__webpack_require__(50);\n__webpack_require__(51);\n__webpack_require__(52);\n__webpack_require__(53);\n__webpack_require__(54);\n__webpack_require__(55);\n__webpack_require__(56);\n__webpack_require__(57);\n__webpack_require__(58);\n__webpack_require__(59);\n__webpack_require__(60);\n__webpack_require__(61);\n__webpack_require__(62);\n__webpack_require__(63);\n__webpack_require__(64);\n__webpack_require__(65);\n__webpack_require__(66);\n__webpack_require__(67);\n__webpack_require__(68);\n__webpack_require__(69);\n__webpack_require__(70);\n__webpack_require__(71);\n__webpack_require__(72);\n__webpack_require__(73);\n__webpack_require__(74);\n__webpack_require__(75);\n__webpack_require__(76);\n__webpack_require__(77);\n__webpack_require__(78);\n__webpack_require__(79);\n__webpack_require__(80);\n__webpack_require__(81);\n__webpack_require__(82);\n__webpack_require__(83);\n__webpack_require__(84);\n__webpack_require__(85);\n__webpack_require__(86);\n__webpack_require__(88);\n__webpack_require__(90);\n__webpack_require__(91);\n__webpack_require__(93);\n__webpack_require__(95);\n__webpack_require__(97);\n__webpack_require__(98);\n__webpack_require__(99);\n__webpack_require__(100);\nup.framework.onEvaled();\n\n})();\n\n/******/ })()\n;", "export default new class Environment {\n\n get toString() {\n return document.body.getAttribute('data-environment')\n }\n\n get isTest() {\n return this.toString === 'test'\n }\n\n get isDevelopment() {\n return this.toString === 'development'\n }\n\n get isFeatureSpec() {\n return this.isTest && typeof jasmine === 'undefined'\n }\n\n}()\n", "import environment from '../util/environment'\n\nup.layer.config.modal.dismissable = 'button key' // do not allow closing modals by clicking the backdrop\n\nup.link.config.followSelectors.push('a[href]')\nup.link.config.instantSelectors.push('a[href]')\nup.link.config.noInstantSelectors.push('.btn:not(.btn-link), [no-instant]')\n\nup.fragment.config.runScripts = false\n\nup.feedback.config.currentClasses.push('active')\n\nup.form.config.submitSelectors.push('form')\n\nup.history.config.updateMetaTags = true\n\nup.motion.config.enabled = !environment.isTest\n\nup.network.config.progressBar = true\n\nup.on('up:network:late', () => { document.body.classList.add('-loading') })\nup.on('up:network:recover', () => { document.body.classList.remove('-loading') })\n", "export function signedIn() {\n return !!document.querySelector('[data-authenticated]')\n}\n", "import '../../shared/config/unpoly.js'\nimport '../../shared/config/unpoly.sass'\nimport { signedIn } from '../util/current_user'\n\nup.link.config.preloadSelectors.push('a[href]')\n\nup.on('up:request:loaded', ({ response }) => {\n if (response.status === 401 && signedIn()) {\n // User was signed out from a previously active session.\n // The 401 response includes an error message that should be displayed.\n\n up.util.task(() => {\n // We delay render cycle so that up:fragment:loaded events (e.g. form submission)\n // don't have to render results on a DOM that does not match their expectations\n // which can result in errors.\n // This means that a form may render the 401 response considering its failTarget\n // for a single frame until we render the the error response as a \"full\" page.\n // This is usually not noticeable, and in any case only relevant for edge cases.\n up.render({\n // close any layers that might be open\n layer: 'root',\n peel: true,\n\n // discard the entire layout, as it might contain information from the user session (e.g. name in header)\n target: 'body',\n document: response.text,\n clearCache: true,\n\n // discard the current URL to avoid leaking personalized URLs\n location: '/',\n history: true,\n })\n })\n }\n})\n", "const scriptsLoaded = {}\n\nexport default function loadScript(url) {\n\n function createScriptTag(url) {\n const scriptTag = document.createElement('script')\n scriptTag.src = url\n return scriptTag\n }\n\n const cachedPromise = scriptsLoaded[url]\n if (cachedPromise) {\n return cachedPromise\n } else {\n const promise = new Promise((resolve, reject) => {\n const scriptTag = createScriptTag(url)\n scriptTag.addEventListener('load', resolve)\n scriptTag.addEventListener('error', reject)\n document.head.appendChild(scriptTag)\n })\n scriptsLoaded[url] = promise\n return promise\n }\n\n}\n", "// Animated icons are rendered using lottie-web's `lottie_light` player.\n// Other implementations, like the \"full\" player, or @dotlottie's player use eval which is forbidden by our CSP.\n//\n// By default, icons play only while hovering a surrounding or \n `,\n size: 'auto',\n })\n }\n\n trackEvent('read-aloud', 'readable-content-present')\n\n up.on(element, 'click', startButtonSelector, onClickButton)\n up.on(element, 'click', stopButtonSelector, onClickButton)\n\n audios.forEach((audio, index) => {\n audio.addEventListener('ended', () => {\n onAudioEnded(audio, index)\n })\n })\n\n updateVisibleButtonText()\n\n if (autoPlay) {\n try {\n await play({ throwError: true }).then(updateVisibleButtonText)\n trackEvent('read-aloud', 'auto-play')\n } catch {\n // Autoplay was prevented\n trackEvent('read-aloud', 'auto-play-prevented')\n }\n }\n\n})\n", "import { trackPageView } from '../util/analytics'\n\nup.compiler('[track-page-view]', (element, data) => {\n trackPageView(data)\n})\n", "/**\n * Custom positioning reference element.\n * @see https://floating-ui.com/docs/virtual-elements\n */\n\nconst sides = ['top', 'right', 'bottom', 'left'];\nconst alignments = ['start', 'end'];\nconst placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + \"-\" + alignments[0], side + \"-\" + alignments[1]), []);\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\nconst floor = Math.floor;\nconst createCoords = v => ({\n x: v,\n y: v\n});\nconst oppositeSideMap = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nconst oppositeAlignmentMap = {\n start: 'end',\n end: 'start'\n};\nfunction clamp(start, value, end) {\n return max(start, min(value, end));\n}\nfunction evaluate(value, param) {\n return typeof value === 'function' ? value(param) : value;\n}\nfunction getSide(placement) {\n return placement.split('-')[0];\n}\nfunction getAlignment(placement) {\n return placement.split('-')[1];\n}\nfunction getOppositeAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}\nfunction getAxisLength(axis) {\n return axis === 'y' ? 'height' : 'width';\n}\nfunction getSideAxis(placement) {\n return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';\n}\nfunction getAlignmentAxis(placement) {\n return getOppositeAxis(getSideAxis(placement));\n}\nfunction getAlignmentSides(placement, rects, rtl) {\n if (rtl === void 0) {\n rtl = false;\n }\n const alignment = getAlignment(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const length = getAxisLength(alignmentAxis);\n let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';\n if (rects.reference[length] > rects.floating[length]) {\n mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n }\n return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];\n}\nfunction getExpandedPlacements(placement) {\n const oppositePlacement = getOppositePlacement(placement);\n return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\nfunction getOppositeAlignmentPlacement(placement) {\n return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);\n}\nfunction getSideList(side, isStart, rtl) {\n const lr = ['left', 'right'];\n const rl = ['right', 'left'];\n const tb = ['top', 'bottom'];\n const bt = ['bottom', 'top'];\n switch (side) {\n case 'top':\n case 'bottom':\n if (rtl) return isStart ? rl : lr;\n return isStart ? lr : rl;\n case 'left':\n case 'right':\n return isStart ? tb : bt;\n default:\n return [];\n }\n}\nfunction getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {\n const alignment = getAlignment(placement);\n let list = getSideList(getSide(placement), direction === 'start', rtl);\n if (alignment) {\n list = list.map(side => side + \"-\" + alignment);\n if (flipAlignment) {\n list = list.concat(list.map(getOppositeAlignmentPlacement));\n }\n }\n return list;\n}\nfunction getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);\n}\nfunction expandPaddingObject(padding) {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n ...padding\n };\n}\nfunction getPaddingObject(padding) {\n return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding\n };\n}\nfunction rectToClientRect(rect) {\n const {\n x,\n y,\n width,\n height\n } = rect;\n return {\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n x,\n y\n };\n}\n\nexport { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };\n", "import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';\nexport { rectToClientRect } from '@floating-ui/utils';\n\nfunction computeCoordsFromPlacement(_ref, placement, rtl) {\n let {\n reference,\n floating\n } = _ref;\n const sideAxis = getSideAxis(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const alignLength = getAxisLength(alignmentAxis);\n const side = getSide(placement);\n const isVertical = sideAxis === 'y';\n const commonX = reference.x + reference.width / 2 - floating.width / 2;\n const commonY = reference.y + reference.height / 2 - floating.height / 2;\n const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;\n let coords;\n switch (side) {\n case 'top':\n coords = {\n x: commonX,\n y: reference.y - floating.height\n };\n break;\n case 'bottom':\n coords = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n case 'right':\n coords = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n case 'left':\n coords = {\n x: reference.x - floating.width,\n y: commonY\n };\n break;\n default:\n coords = {\n x: reference.x,\n y: reference.y\n };\n }\n switch (getAlignment(placement)) {\n case 'start':\n coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n case 'end':\n coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n }\n return coords;\n}\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n *\n * This export does not have any `platform` interface logic. You will need to\n * write one for the platform you are using Floating UI with.\n */\nconst computePosition = async (reference, floating, config) => {\n const {\n placement = 'bottom',\n strategy = 'absolute',\n middleware = [],\n platform\n } = config;\n const validMiddleware = middleware.filter(Boolean);\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));\n let rects = await platform.getElementRects({\n reference,\n floating,\n strategy\n });\n let {\n x,\n y\n } = computeCoordsFromPlacement(rects, placement, rtl);\n let statefulPlacement = placement;\n let middlewareData = {};\n let resetCount = 0;\n for (let i = 0; i < validMiddleware.length; i++) {\n const {\n name,\n fn\n } = validMiddleware[i];\n const {\n x: nextX,\n y: nextY,\n data,\n reset\n } = await fn({\n x,\n y,\n initialPlacement: placement,\n placement: statefulPlacement,\n strategy,\n middlewareData,\n rects,\n platform,\n elements: {\n reference,\n floating\n }\n });\n x = nextX != null ? nextX : x;\n y = nextY != null ? nextY : y;\n middlewareData = {\n ...middlewareData,\n [name]: {\n ...middlewareData[name],\n ...data\n }\n };\n if (reset && resetCount <= 50) {\n resetCount++;\n if (typeof reset === 'object') {\n if (reset.placement) {\n statefulPlacement = reset.placement;\n }\n if (reset.rects) {\n rects = reset.rects === true ? await platform.getElementRects({\n reference,\n floating,\n strategy\n }) : reset.rects;\n }\n ({\n x,\n y\n } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));\n }\n i = -1;\n }\n }\n return {\n x,\n y,\n placement: statefulPlacement,\n strategy,\n middlewareData\n };\n};\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nasync function detectOverflow(state, options) {\n var _await$platform$isEle;\n if (options === void 0) {\n options = {};\n }\n const {\n x,\n y,\n platform,\n rects,\n elements,\n strategy\n } = state;\n const {\n boundary = 'clippingAncestors',\n rootBoundary = 'viewport',\n elementContext = 'floating',\n altBoundary = false,\n padding = 0\n } = evaluate(options, state);\n const paddingObject = getPaddingObject(padding);\n const altContext = elementContext === 'floating' ? 'reference' : 'floating';\n const element = elements[altBoundary ? altContext : elementContext];\n const clippingClientRect = rectToClientRect(await platform.getClippingRect({\n element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),\n boundary,\n rootBoundary,\n strategy\n }));\n const rect = elementContext === 'floating' ? {\n x,\n y,\n width: rects.floating.width,\n height: rects.floating.height\n } : rects.reference;\n const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));\n const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {\n x: 1,\n y: 1\n } : {\n x: 1,\n y: 1\n };\n const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n elements,\n rect,\n offsetParent,\n strategy\n }) : rect);\n return {\n top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,\n bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,\n left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,\n right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x\n };\n}\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = options => ({\n name: 'arrow',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n platform,\n elements,\n middlewareData\n } = state;\n // Since `element` is required, we don't Partial<> the type.\n const {\n element,\n padding = 0\n } = evaluate(options, state) || {};\n if (element == null) {\n return {};\n }\n const paddingObject = getPaddingObject(padding);\n const coords = {\n x,\n y\n };\n const axis = getAlignmentAxis(placement);\n const length = getAxisLength(axis);\n const arrowDimensions = await platform.getDimensions(element);\n const isYAxis = axis === 'y';\n const minProp = isYAxis ? 'top' : 'left';\n const maxProp = isYAxis ? 'bottom' : 'right';\n const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';\n const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];\n const startDiff = coords[axis] - rects.reference[axis];\n const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));\n let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;\n\n // DOM platform can return `window` as the `offsetParent`.\n if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {\n clientSize = elements.floating[clientProp] || rects.floating[length];\n }\n const centerToReference = endDiff / 2 - startDiff / 2;\n\n // If the padding is large enough that it causes the arrow to no longer be\n // centered, modify the padding so that it is centered.\n const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;\n const minPadding = min(paddingObject[minProp], largestPossiblePadding);\n const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);\n\n // Make sure the arrow doesn't overflow the floating element if the center\n // point is outside the floating element's bounds.\n const min$1 = minPadding;\n const max = clientSize - arrowDimensions[length] - maxPadding;\n const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;\n const offset = clamp(min$1, center, max);\n\n // If the reference is small enough that the arrow's padding causes it to\n // to point to nothing for an aligned placement, adjust the offset of the\n // floating element itself. To ensure `shift()` continues to take action,\n // a single reset is performed when this is true.\n const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;\n const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;\n return {\n [axis]: coords[axis] + alignmentOffset,\n data: {\n [axis]: offset,\n centerOffset: center - offset - alignmentOffset,\n ...(shouldAddOffset && {\n alignmentOffset\n })\n },\n reset: shouldAddOffset\n };\n }\n});\n\nfunction getPlacementList(alignment, autoAlignment, allowedPlacements) {\n const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);\n return allowedPlacementsSortedByAlignment.filter(placement => {\n if (alignment) {\n return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);\n }\n return true;\n });\n}\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'autoPlacement',\n options,\n async fn(state) {\n var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;\n const {\n rects,\n middlewareData,\n placement,\n platform,\n elements\n } = state;\n const {\n crossAxis = false,\n alignment,\n allowedPlacements = placements,\n autoAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;\n const overflow = await detectOverflow(state, detectOverflowOptions);\n const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;\n const currentPlacement = placements$1[currentIndex];\n if (currentPlacement == null) {\n return {};\n }\n const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));\n\n // Make `computeCoords` start from the right place.\n if (placement !== currentPlacement) {\n return {\n reset: {\n placement: placements$1[0]\n }\n };\n }\n const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];\n const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {\n placement: currentPlacement,\n overflows: currentOverflows\n }];\n const nextPlacement = placements$1[currentIndex + 1];\n\n // There are more placements to check.\n if (nextPlacement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n const placementsSortedByMostSpace = allOverflows.map(d => {\n const alignment = getAlignment(d.placement);\n return [d.placement, alignment && crossAxis ?\n // Check along the mainAxis and main crossAxis side.\n d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :\n // Check only the mainAxis.\n d.overflows[0], d.overflows];\n }).sort((a, b) => a[1] - b[1]);\n const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,\n // Aligned placements should not check their opposite crossAxis\n // side.\n getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));\n const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];\n if (resetPlacement !== placement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: resetPlacement\n }\n };\n }\n return {};\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'flip',\n options,\n async fn(state) {\n var _middlewareData$arrow, _middlewareData$flip;\n const {\n placement,\n middlewareData,\n rects,\n initialPlacement,\n platform,\n elements\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true,\n fallbackPlacements: specifiedFallbackPlacements,\n fallbackStrategy = 'bestFit',\n fallbackAxisSideDirection = 'none',\n flipAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n\n // If a reset by the arrow was caused due to an alignment offset being\n // added, we should skip any logic now since `flip()` has already done its\n // work.\n // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643\n if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n const side = getSide(placement);\n const initialSideAxis = getSideAxis(initialPlacement);\n const isBasePlacement = getSide(initialPlacement) === initialPlacement;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));\n const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';\n if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {\n fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));\n }\n const placements = [initialPlacement, ...fallbackPlacements];\n const overflow = await detectOverflow(state, detectOverflowOptions);\n const overflows = [];\n let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];\n if (checkMainAxis) {\n overflows.push(overflow[side]);\n }\n if (checkCrossAxis) {\n const sides = getAlignmentSides(placement, rects, rtl);\n overflows.push(overflow[sides[0]], overflow[sides[1]]);\n }\n overflowsData = [...overflowsData, {\n placement,\n overflows\n }];\n\n // One or more sides is overflowing.\n if (!overflows.every(side => side <= 0)) {\n var _middlewareData$flip2, _overflowsData$filter;\n const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;\n const nextPlacement = placements[nextIndex];\n if (nextPlacement) {\n // Try next placement and re-run the lifecycle.\n return {\n data: {\n index: nextIndex,\n overflows: overflowsData\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n\n // First, find the candidates that fit on the mainAxis side of overflow,\n // then find the placement that fits the best on the main crossAxis side.\n let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;\n\n // Otherwise fallback.\n if (!resetPlacement) {\n switch (fallbackStrategy) {\n case 'bestFit':\n {\n var _overflowsData$filter2;\n const placement = (_overflowsData$filter2 = overflowsData.filter(d => {\n if (hasFallbackAxisSideDirection) {\n const currentSideAxis = getSideAxis(d.placement);\n return currentSideAxis === initialSideAxis ||\n // Create a bias to the `y` side axis due to horizontal\n // reading directions favoring greater width.\n currentSideAxis === 'y';\n }\n return true;\n }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];\n if (placement) {\n resetPlacement = placement;\n }\n break;\n }\n case 'initialPlacement':\n resetPlacement = initialPlacement;\n break;\n }\n }\n if (placement !== resetPlacement) {\n return {\n reset: {\n placement: resetPlacement\n }\n };\n }\n }\n return {};\n }\n };\n};\n\nfunction getSideOffsets(overflow, rect) {\n return {\n top: overflow.top - rect.height,\n right: overflow.right - rect.width,\n bottom: overflow.bottom - rect.height,\n left: overflow.left - rect.width\n };\n}\nfunction isAnySideFullyClipped(overflow) {\n return sides.some(side => overflow[side] >= 0);\n}\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'hide',\n options,\n async fn(state) {\n const {\n rects\n } = state;\n const {\n strategy = 'referenceHidden',\n ...detectOverflowOptions\n } = evaluate(options, state);\n switch (strategy) {\n case 'referenceHidden':\n {\n const overflow = await detectOverflow(state, {\n ...detectOverflowOptions,\n elementContext: 'reference'\n });\n const offsets = getSideOffsets(overflow, rects.reference);\n return {\n data: {\n referenceHiddenOffsets: offsets,\n referenceHidden: isAnySideFullyClipped(offsets)\n }\n };\n }\n case 'escaped':\n {\n const overflow = await detectOverflow(state, {\n ...detectOverflowOptions,\n altBoundary: true\n });\n const offsets = getSideOffsets(overflow, rects.floating);\n return {\n data: {\n escapedOffsets: offsets,\n escaped: isAnySideFullyClipped(offsets)\n }\n };\n }\n default:\n {\n return {};\n }\n }\n }\n };\n};\n\nfunction getBoundingRect(rects) {\n const minX = min(...rects.map(rect => rect.left));\n const minY = min(...rects.map(rect => rect.top));\n const maxX = max(...rects.map(rect => rect.right));\n const maxY = max(...rects.map(rect => rect.bottom));\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY\n };\n}\nfunction getRectsByLine(rects) {\n const sortedRects = rects.slice().sort((a, b) => a.y - b.y);\n const groups = [];\n let prevRect = null;\n for (let i = 0; i < sortedRects.length; i++) {\n const rect = sortedRects[i];\n if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {\n groups.push([rect]);\n } else {\n groups[groups.length - 1].push(rect);\n }\n prevRect = rect;\n }\n return groups.map(rect => rectToClientRect(getBoundingRect(rect)));\n}\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'inline',\n options,\n async fn(state) {\n const {\n placement,\n elements,\n rects,\n platform,\n strategy\n } = state;\n // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a\n // ClientRect's bounds, despite the event listener being triggered. A\n // padding of 2 seems to handle this issue.\n const {\n padding = 2,\n x,\n y\n } = evaluate(options, state);\n const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);\n const clientRects = getRectsByLine(nativeClientRects);\n const fallback = rectToClientRect(getBoundingRect(nativeClientRects));\n const paddingObject = getPaddingObject(padding);\n function getBoundingClientRect() {\n // There are two rects and they are disjoined.\n if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {\n // Find the first rect in which the point is fully inside.\n return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;\n }\n\n // There are 2 or more connected rects.\n if (clientRects.length >= 2) {\n if (getSideAxis(placement) === 'y') {\n const firstRect = clientRects[0];\n const lastRect = clientRects[clientRects.length - 1];\n const isTop = getSide(placement) === 'top';\n const top = firstRect.top;\n const bottom = lastRect.bottom;\n const left = isTop ? firstRect.left : lastRect.left;\n const right = isTop ? firstRect.right : lastRect.right;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n const isLeftSide = getSide(placement) === 'left';\n const maxRight = max(...clientRects.map(rect => rect.right));\n const minLeft = min(...clientRects.map(rect => rect.left));\n const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);\n const top = measureRects[0].top;\n const bottom = measureRects[measureRects.length - 1].bottom;\n const left = minLeft;\n const right = maxRight;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n return fallback;\n }\n const resetRects = await platform.getElementRects({\n reference: {\n getBoundingClientRect\n },\n floating: elements.floating,\n strategy\n });\n if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {\n return {\n reset: {\n rects: resetRects\n }\n };\n }\n return {};\n }\n };\n};\n\n// For type backwards-compatibility, the `OffsetOptions` type was also\n// Derivable.\n\nasync function convertValueToCoords(state, options) {\n const {\n placement,\n platform,\n elements\n } = state;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isVertical = getSideAxis(placement) === 'y';\n const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;\n const crossAxisMulti = rtl && isVertical ? -1 : 1;\n const rawValue = evaluate(options, state);\n\n // eslint-disable-next-line prefer-const\n let {\n mainAxis,\n crossAxis,\n alignmentAxis\n } = typeof rawValue === 'number' ? {\n mainAxis: rawValue,\n crossAxis: 0,\n alignmentAxis: null\n } : {\n mainAxis: rawValue.mainAxis || 0,\n crossAxis: rawValue.crossAxis || 0,\n alignmentAxis: rawValue.alignmentAxis\n };\n if (alignment && typeof alignmentAxis === 'number') {\n crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;\n }\n return isVertical ? {\n x: crossAxis * crossAxisMulti,\n y: mainAxis * mainAxisMulti\n } : {\n x: mainAxis * mainAxisMulti,\n y: crossAxis * crossAxisMulti\n };\n}\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = function (options) {\n if (options === void 0) {\n options = 0;\n }\n return {\n name: 'offset',\n options,\n async fn(state) {\n var _middlewareData$offse, _middlewareData$arrow;\n const {\n x,\n y,\n placement,\n middlewareData\n } = state;\n const diffCoords = await convertValueToCoords(state, options);\n\n // If the placement is the same and the arrow caused an alignment offset\n // then we don't need to change the positioning coordinates.\n if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: {\n ...diffCoords,\n placement\n }\n };\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'shift',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = false,\n limiter = {\n fn: _ref => {\n let {\n x,\n y\n } = _ref;\n return {\n x,\n y\n };\n }\n },\n ...detectOverflowOptions\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const overflow = await detectOverflow(state, detectOverflowOptions);\n const crossAxis = getSideAxis(getSide(placement));\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n if (checkMainAxis) {\n const minSide = mainAxis === 'y' ? 'top' : 'left';\n const maxSide = mainAxis === 'y' ? 'bottom' : 'right';\n const min = mainAxisCoord + overflow[minSide];\n const max = mainAxisCoord - overflow[maxSide];\n mainAxisCoord = clamp(min, mainAxisCoord, max);\n }\n if (checkCrossAxis) {\n const minSide = crossAxis === 'y' ? 'top' : 'left';\n const maxSide = crossAxis === 'y' ? 'bottom' : 'right';\n const min = crossAxisCoord + overflow[minSide];\n const max = crossAxisCoord - overflow[maxSide];\n crossAxisCoord = clamp(min, crossAxisCoord, max);\n }\n const limitedCoords = limiter.fn({\n ...state,\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n });\n return {\n ...limitedCoords,\n data: {\n x: limitedCoords.x - x,\n y: limitedCoords.y - y,\n enabled: {\n [mainAxis]: checkMainAxis,\n [crossAxis]: checkCrossAxis\n }\n }\n };\n }\n };\n};\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n options,\n fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n middlewareData\n } = state;\n const {\n offset = 0,\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const crossAxis = getSideAxis(placement);\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n const rawOffset = evaluate(offset, state);\n const computedOffset = typeof rawOffset === 'number' ? {\n mainAxis: rawOffset,\n crossAxis: 0\n } : {\n mainAxis: 0,\n crossAxis: 0,\n ...rawOffset\n };\n if (checkMainAxis) {\n const len = mainAxis === 'y' ? 'height' : 'width';\n const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;\n const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;\n if (mainAxisCoord < limitMin) {\n mainAxisCoord = limitMin;\n } else if (mainAxisCoord > limitMax) {\n mainAxisCoord = limitMax;\n }\n }\n if (checkCrossAxis) {\n var _middlewareData$offse, _middlewareData$offse2;\n const len = mainAxis === 'y' ? 'width' : 'height';\n const isOriginSide = ['top', 'left'].includes(getSide(placement));\n const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);\n const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);\n if (crossAxisCoord < limitMin) {\n crossAxisCoord = limitMin;\n } else if (crossAxisCoord > limitMax) {\n crossAxisCoord = limitMax;\n }\n }\n return {\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n };\n }\n };\n};\n\n/**\n * Provides data that allows you to change the size of the floating element \u2014\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'size',\n options,\n async fn(state) {\n var _state$middlewareData, _state$middlewareData2;\n const {\n placement,\n rects,\n platform,\n elements\n } = state;\n const {\n apply = () => {},\n ...detectOverflowOptions\n } = evaluate(options, state);\n const overflow = await detectOverflow(state, detectOverflowOptions);\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isYAxis = getSideAxis(placement) === 'y';\n const {\n width,\n height\n } = rects.floating;\n let heightSide;\n let widthSide;\n if (side === 'top' || side === 'bottom') {\n heightSide = side;\n widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';\n } else {\n widthSide = side;\n heightSide = alignment === 'end' ? 'top' : 'bottom';\n }\n const maximumClippingHeight = height - overflow.top - overflow.bottom;\n const maximumClippingWidth = width - overflow.left - overflow.right;\n const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);\n const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);\n const noShift = !state.middlewareData.shift;\n let availableHeight = overflowAvailableHeight;\n let availableWidth = overflowAvailableWidth;\n if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {\n availableWidth = maximumClippingWidth;\n }\n if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {\n availableHeight = maximumClippingHeight;\n }\n if (noShift && !alignment) {\n const xMin = max(overflow.left, 0);\n const xMax = max(overflow.right, 0);\n const yMin = max(overflow.top, 0);\n const yMax = max(overflow.bottom, 0);\n if (isYAxis) {\n availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));\n } else {\n availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));\n }\n }\n await apply({\n ...state,\n availableWidth,\n availableHeight\n });\n const nextDimensions = await platform.getDimensions(elements.floating);\n if (width !== nextDimensions.width || height !== nextDimensions.height) {\n return {\n reset: {\n rects: true\n }\n };\n }\n return {};\n }\n };\n};\n\nexport { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };\n", "function hasWindow() {\n return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n if (isNode(node)) {\n return (node.nodeName || '').toLowerCase();\n }\n // Mocked nodes in testing environments may not be instances of Node. By\n // returning `#document` an infinite loop won't occur.\n // https://github.com/floating-ui/floating-ui/issues/2317\n return '#document';\n}\nfunction getWindow(node) {\n var _node$ownerDocument;\n return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n var _ref;\n return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n return false;\n }\n return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nfunction isOverflowElement(element) {\n const {\n overflow,\n overflowX,\n overflowY,\n display\n } = getComputedStyle(element);\n return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);\n}\nfunction isTableElement(element) {\n return ['table', 'td', 'th'].includes(getNodeName(element));\n}\nfunction isTopLayer(element) {\n return [':popover-open', ':modal'].some(selector => {\n try {\n return element.matches(selector);\n } catch (e) {\n return false;\n }\n });\n}\nfunction isContainingBlock(elementOrCss) {\n const webkit = isWebKit();\n const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));\n}\nfunction getContainingBlock(element) {\n let currentNode = getParentNode(element);\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else if (isTopLayer(currentNode)) {\n return null;\n }\n currentNode = getParentNode(currentNode);\n }\n return null;\n}\nfunction isWebKit() {\n if (typeof CSS === 'undefined' || !CSS.supports) return false;\n return CSS.supports('-webkit-backdrop-filter', 'none');\n}\nfunction isLastTraversableNode(node) {\n return ['html', 'body', '#document'].includes(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n if (isElement(element)) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n }\n return {\n scrollLeft: element.scrollX,\n scrollTop: element.scrollY\n };\n}\nfunction getParentNode(node) {\n if (getNodeName(node) === 'html') {\n return node;\n }\n const result =\n // Step into the shadow DOM of the parent of a slotted node.\n node.assignedSlot ||\n // DOM Element detected.\n node.parentNode ||\n // ShadowRoot detected.\n isShadowRoot(node) && node.host ||\n // Fallback.\n getDocumentElement(node);\n return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n const parentNode = getParentNode(node);\n if (isLastTraversableNode(parentNode)) {\n return node.ownerDocument ? node.ownerDocument.body : node.body;\n }\n if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n return parentNode;\n }\n return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n var _node$ownerDocument2;\n if (list === void 0) {\n list = [];\n }\n if (traverseIframes === void 0) {\n traverseIframes = true;\n }\n const scrollableAncestor = getNearestOverflowAncestor(node);\n const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n const win = getWindow(scrollableAncestor);\n if (isBody) {\n const frameElement = getFrameElement(win);\n return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n }\n return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n}\nfunction getFrameElement(win) {\n return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n", "import { rectToClientRect, detectOverflow as detectOverflow$1, offset as offset$1, autoPlacement as autoPlacement$1, shift as shift$1, flip as flip$1, size as size$1, hide as hide$1, arrow as arrow$1, inline as inline$1, limitShift as limitShift$1, computePosition as computePosition$1 } from '@floating-ui/core';\nimport { round, createCoords, max, min, floor } from '@floating-ui/utils';\nimport { getComputedStyle, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getNodeScroll, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';\nexport { getOverflowAncestors } from '@floating-ui/utils/dom';\n\nfunction getCssDimensions(element) {\n const css = getComputedStyle(element);\n // In testing environments, the `width` and `height` properties are empty\n // strings for SVG elements, returning NaN. Fallback to `0` in this case.\n let width = parseFloat(css.width) || 0;\n let height = parseFloat(css.height) || 0;\n const hasOffset = isHTMLElement(element);\n const offsetWidth = hasOffset ? element.offsetWidth : width;\n const offsetHeight = hasOffset ? element.offsetHeight : height;\n const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;\n if (shouldFallback) {\n width = offsetWidth;\n height = offsetHeight;\n }\n return {\n width,\n height,\n $: shouldFallback\n };\n}\n\nfunction unwrapElement(element) {\n return !isElement(element) ? element.contextElement : element;\n}\n\nfunction getScale(element) {\n const domElement = unwrapElement(element);\n if (!isHTMLElement(domElement)) {\n return createCoords(1);\n }\n const rect = domElement.getBoundingClientRect();\n const {\n width,\n height,\n $\n } = getCssDimensions(domElement);\n let x = ($ ? round(rect.width) : rect.width) / width;\n let y = ($ ? round(rect.height) : rect.height) / height;\n\n // 0, NaN, or Infinity should always fallback to 1.\n\n if (!x || !Number.isFinite(x)) {\n x = 1;\n }\n if (!y || !Number.isFinite(y)) {\n y = 1;\n }\n return {\n x,\n y\n };\n}\n\nconst noOffsets = /*#__PURE__*/createCoords(0);\nfunction getVisualOffsets(element) {\n const win = getWindow(element);\n if (!isWebKit() || !win.visualViewport) {\n return noOffsets;\n }\n return {\n x: win.visualViewport.offsetLeft,\n y: win.visualViewport.offsetTop\n };\n}\nfunction shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {\n return false;\n }\n return isFixed;\n}\n\nfunction getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {\n if (includeScale === void 0) {\n includeScale = false;\n }\n if (isFixedStrategy === void 0) {\n isFixedStrategy = false;\n }\n const clientRect = element.getBoundingClientRect();\n const domElement = unwrapElement(element);\n let scale = createCoords(1);\n if (includeScale) {\n if (offsetParent) {\n if (isElement(offsetParent)) {\n scale = getScale(offsetParent);\n }\n } else {\n scale = getScale(element);\n }\n }\n const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);\n let x = (clientRect.left + visualOffsets.x) / scale.x;\n let y = (clientRect.top + visualOffsets.y) / scale.y;\n let width = clientRect.width / scale.x;\n let height = clientRect.height / scale.y;\n if (domElement) {\n const win = getWindow(domElement);\n const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;\n let currentWin = win;\n let currentIFrame = getFrameElement(currentWin);\n while (currentIFrame && offsetParent && offsetWin !== currentWin) {\n const iframeScale = getScale(currentIFrame);\n const iframeRect = currentIFrame.getBoundingClientRect();\n const css = getComputedStyle(currentIFrame);\n const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;\n const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;\n x *= iframeScale.x;\n y *= iframeScale.y;\n width *= iframeScale.x;\n height *= iframeScale.y;\n x += left;\n y += top;\n currentWin = getWindow(currentIFrame);\n currentIFrame = getFrameElement(currentWin);\n }\n }\n return rectToClientRect({\n width,\n height,\n x,\n y\n });\n}\n\nfunction convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {\n let {\n elements,\n rect,\n offsetParent,\n strategy\n } = _ref;\n const isFixed = strategy === 'fixed';\n const documentElement = getDocumentElement(offsetParent);\n const topLayer = elements ? isTopLayer(elements.floating) : false;\n if (offsetParent === documentElement || topLayer && isFixed) {\n return rect;\n }\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n let scale = createCoords(1);\n const offsets = createCoords(0);\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isHTMLElement(offsetParent)) {\n const offsetRect = getBoundingClientRect(offsetParent);\n scale = getScale(offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n }\n }\n return {\n width: rect.width * scale.x,\n height: rect.height * scale.y,\n x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,\n y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y\n };\n}\n\nfunction getClientRects(element) {\n return Array.from(element.getClientRects());\n}\n\n// If has a CSS width greater than the viewport, then this will be\n// incorrect for RTL.\nfunction getWindowScrollBarX(element, rect) {\n const leftScroll = getNodeScroll(element).scrollLeft;\n if (!rect) {\n return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;\n }\n return rect.left + leftScroll;\n}\n\n// Gets the entire size of the scrollable document area, even extending outside\n// of the `` and `` rect bounds if horizontally scrollable.\nfunction getDocumentRect(element) {\n const html = getDocumentElement(element);\n const scroll = getNodeScroll(element);\n const body = element.ownerDocument.body;\n const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);\n const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);\n let x = -scroll.scrollLeft + getWindowScrollBarX(element);\n const y = -scroll.scrollTop;\n if (getComputedStyle(body).direction === 'rtl') {\n x += max(html.clientWidth, body.clientWidth) - width;\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\nfunction getViewportRect(element, strategy) {\n const win = getWindow(element);\n const html = getDocumentElement(element);\n const visualViewport = win.visualViewport;\n let width = html.clientWidth;\n let height = html.clientHeight;\n let x = 0;\n let y = 0;\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height;\n const visualViewportBased = isWebKit();\n if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\n// Returns the inner client rect, subtracting scrollbars if present.\nfunction getInnerBoundingClientRect(element, strategy) {\n const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');\n const top = clientRect.top + element.clientTop;\n const left = clientRect.left + element.clientLeft;\n const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);\n const width = element.clientWidth * scale.x;\n const height = element.clientHeight * scale.y;\n const x = left * scale.x;\n const y = top * scale.y;\n return {\n width,\n height,\n x,\n y\n };\n}\nfunction getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {\n let rect;\n if (clippingAncestor === 'viewport') {\n rect = getViewportRect(element, strategy);\n } else if (clippingAncestor === 'document') {\n rect = getDocumentRect(getDocumentElement(element));\n } else if (isElement(clippingAncestor)) {\n rect = getInnerBoundingClientRect(clippingAncestor, strategy);\n } else {\n const visualOffsets = getVisualOffsets(element);\n rect = {\n ...clippingAncestor,\n x: clippingAncestor.x - visualOffsets.x,\n y: clippingAncestor.y - visualOffsets.y\n };\n }\n return rectToClientRect(rect);\n}\nfunction hasFixedPositionAncestor(element, stopNode) {\n const parentNode = getParentNode(element);\n if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {\n return false;\n }\n return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);\n}\n\n// A \"clipping ancestor\" is an `overflow` element with the characteristic of\n// clipping (or hiding) child elements. This returns all clipping ancestors\n// of the given element up the tree.\nfunction getClippingElementAncestors(element, cache) {\n const cachedResult = cache.get(element);\n if (cachedResult) {\n return cachedResult;\n }\n let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');\n let currentContainingBlockComputedStyle = null;\n const elementIsFixed = getComputedStyle(element).position === 'fixed';\n let currentNode = elementIsFixed ? getParentNode(element) : element;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {\n const computedStyle = getComputedStyle(currentNode);\n const currentNodeIsContaining = isContainingBlock(currentNode);\n if (!currentNodeIsContaining && computedStyle.position === 'fixed') {\n currentContainingBlockComputedStyle = null;\n }\n const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);\n if (shouldDropCurrentNode) {\n // Drop non-containing blocks.\n result = result.filter(ancestor => ancestor !== currentNode);\n } else {\n // Record last containing block for next iteration.\n currentContainingBlockComputedStyle = computedStyle;\n }\n currentNode = getParentNode(currentNode);\n }\n cache.set(element, result);\n return result;\n}\n\n// Gets the maximum area that the element is visible in due to any number of\n// clipping ancestors.\nfunction getClippingRect(_ref) {\n let {\n element,\n boundary,\n rootBoundary,\n strategy\n } = _ref;\n const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);\n const clippingAncestors = [...elementClippingAncestors, rootBoundary];\n const firstClippingAncestor = clippingAncestors[0];\n const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {\n const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);\n accRect.top = max(rect.top, accRect.top);\n accRect.right = min(rect.right, accRect.right);\n accRect.bottom = min(rect.bottom, accRect.bottom);\n accRect.left = max(rect.left, accRect.left);\n return accRect;\n }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));\n return {\n width: clippingRect.right - clippingRect.left,\n height: clippingRect.bottom - clippingRect.top,\n x: clippingRect.left,\n y: clippingRect.top\n };\n}\n\nfunction getDimensions(element) {\n const {\n width,\n height\n } = getCssDimensions(element);\n return {\n width,\n height\n };\n}\n\nfunction getRectRelativeToOffsetParent(element, offsetParent, strategy) {\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n const documentElement = getDocumentElement(offsetParent);\n const isFixed = strategy === 'fixed';\n const rect = getBoundingClientRect(element, true, isFixed, offsetParent);\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n const offsets = createCoords(0);\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isOffsetParentAnElement) {\n const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n } else if (documentElement) {\n // If the scrollbar appears on the left (e.g. RTL systems). Use\n // Firefox with layout.scrollbar.side = 3 in about:config to test this.\n offsets.x = getWindowScrollBarX(documentElement);\n }\n }\n let htmlX = 0;\n let htmlY = 0;\n if (documentElement && !isOffsetParentAnElement && !isFixed) {\n const htmlRect = documentElement.getBoundingClientRect();\n htmlY = htmlRect.top + scroll.scrollTop;\n htmlX = htmlRect.left + scroll.scrollLeft -\n // RTL scrollbar.\n getWindowScrollBarX(documentElement, htmlRect);\n }\n const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;\n const y = rect.top + scroll.scrollTop - offsets.y - htmlY;\n return {\n x,\n y,\n width: rect.width,\n height: rect.height\n };\n}\n\nfunction isStaticPositioned(element) {\n return getComputedStyle(element).position === 'static';\n}\n\nfunction getTrueOffsetParent(element, polyfill) {\n if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {\n return null;\n }\n if (polyfill) {\n return polyfill(element);\n }\n let rawOffsetParent = element.offsetParent;\n\n // Firefox returns the element as the offsetParent if it's non-static,\n // while Chrome and Safari return the element. The element must\n // be used to perform the correct calculations even if the element is\n // non-static.\n if (getDocumentElement(element) === rawOffsetParent) {\n rawOffsetParent = rawOffsetParent.ownerDocument.body;\n }\n return rawOffsetParent;\n}\n\n// Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\nfunction getOffsetParent(element, polyfill) {\n const win = getWindow(element);\n if (isTopLayer(element)) {\n return win;\n }\n if (!isHTMLElement(element)) {\n let svgOffsetParent = getParentNode(element);\n while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {\n if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {\n return svgOffsetParent;\n }\n svgOffsetParent = getParentNode(svgOffsetParent);\n }\n return win;\n }\n let offsetParent = getTrueOffsetParent(element, polyfill);\n while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {\n offsetParent = getTrueOffsetParent(offsetParent, polyfill);\n }\n if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {\n return win;\n }\n return offsetParent || getContainingBlock(element) || win;\n}\n\nconst getElementRects = async function (data) {\n const getOffsetParentFn = this.getOffsetParent || getOffsetParent;\n const getDimensionsFn = this.getDimensions;\n const floatingDimensions = await getDimensionsFn(data.floating);\n return {\n reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),\n floating: {\n x: 0,\n y: 0,\n width: floatingDimensions.width,\n height: floatingDimensions.height\n }\n };\n};\n\nfunction isRTL(element) {\n return getComputedStyle(element).direction === 'rtl';\n}\n\nconst platform = {\n convertOffsetParentRelativeRectToViewportRelativeRect,\n getDocumentElement,\n getClippingRect,\n getOffsetParent,\n getElementRects,\n getClientRects,\n getDimensions,\n getScale,\n isElement,\n isRTL\n};\n\n// https://samthor.au/2021/observing-dom/\nfunction observeMove(element, onMove) {\n let io = null;\n let timeoutId;\n const root = getDocumentElement(element);\n function cleanup() {\n var _io;\n clearTimeout(timeoutId);\n (_io = io) == null || _io.disconnect();\n io = null;\n }\n function refresh(skip, threshold) {\n if (skip === void 0) {\n skip = false;\n }\n if (threshold === void 0) {\n threshold = 1;\n }\n cleanup();\n const {\n left,\n top,\n width,\n height\n } = element.getBoundingClientRect();\n if (!skip) {\n onMove();\n }\n if (!width || !height) {\n return;\n }\n const insetTop = floor(top);\n const insetRight = floor(root.clientWidth - (left + width));\n const insetBottom = floor(root.clientHeight - (top + height));\n const insetLeft = floor(left);\n const rootMargin = -insetTop + \"px \" + -insetRight + \"px \" + -insetBottom + \"px \" + -insetLeft + \"px\";\n const options = {\n rootMargin,\n threshold: max(0, min(1, threshold)) || 1\n };\n let isFirstUpdate = true;\n function handleObserve(entries) {\n const ratio = entries[0].intersectionRatio;\n if (ratio !== threshold) {\n if (!isFirstUpdate) {\n return refresh();\n }\n if (!ratio) {\n // If the reference is clipped, the ratio is 0. Throttle the refresh\n // to prevent an infinite loop of updates.\n timeoutId = setTimeout(() => {\n refresh(false, 1e-7);\n }, 1000);\n } else {\n refresh(false, ratio);\n }\n }\n isFirstUpdate = false;\n }\n\n // Older browsers don't support a `document` as the root and will throw an\n // error.\n try {\n io = new IntersectionObserver(handleObserve, {\n ...options,\n // Handle