{
"version": 3,
"sources": ["../../node_modules/mousetrap/mousetrap.js", "../../node_modules/textarea-caret/index.js", "../../node_modules/fast-myers-diff/bin/index.js", "../../node_modules/autosize/dist/autosize.esm.js", "../../static/index.mjs", "../../node_modules/compute-scroll-into-view/src/index.ts", "../../node_modules/scroll-into-view-if-needed/src/index.ts", "../../node_modules/@popperjs/core/lib/enums.js", "../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js", "../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js", "../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js", "../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js", "../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js", "../../node_modules/@popperjs/core/lib/utils/math.js", "../../node_modules/@popperjs/core/lib/utils/userAgent.js", "../../node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js", "../../node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js", "../../node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js", "../../node_modules/@popperjs/core/lib/dom-utils/contains.js", "../../node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js", "../../node_modules/@popperjs/core/lib/dom-utils/isTableElement.js", "../../node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js", "../../node_modules/@popperjs/core/lib/dom-utils/getParentNode.js", "../../node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js", "../../node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js", "../../node_modules/@popperjs/core/lib/utils/within.js", "../../node_modules/@popperjs/core/lib/utils/getFreshSideObject.js", "../../node_modules/@popperjs/core/lib/utils/mergePaddingObject.js", "../../node_modules/@popperjs/core/lib/utils/expandToHashMap.js", "../../node_modules/@popperjs/core/lib/modifiers/arrow.js", "../../node_modules/@popperjs/core/lib/utils/getVariation.js", "../../node_modules/@popperjs/core/lib/modifiers/computeStyles.js", "../../node_modules/@popperjs/core/lib/modifiers/eventListeners.js", "../../node_modules/@popperjs/core/lib/utils/getOppositePlacement.js", "../../node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js", "../../node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js", "../../node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js", "../../node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js", "../../node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js", "../../node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js", "../../node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js", "../../node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js", "../../node_modules/@popperjs/core/lib/utils/rectToClientRect.js", "../../node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js", "../../node_modules/@popperjs/core/lib/utils/computeOffsets.js", "../../node_modules/@popperjs/core/lib/utils/detectOverflow.js", "../../node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js", "../../node_modules/@popperjs/core/lib/modifiers/flip.js", "../../node_modules/@popperjs/core/lib/modifiers/hide.js", "../../node_modules/@popperjs/core/lib/modifiers/offset.js", "../../node_modules/@popperjs/core/lib/modifiers/popperOffsets.js", "../../node_modules/@popperjs/core/lib/utils/getAltAxis.js", "../../node_modules/@popperjs/core/lib/modifiers/preventOverflow.js", "../../node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js", "../../node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js", "../../node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js", "../../node_modules/@popperjs/core/lib/utils/orderModifiers.js", "../../node_modules/@popperjs/core/lib/utils/debounce.js", "../../node_modules/@popperjs/core/lib/utils/mergeByName.js", "../../node_modules/@popperjs/core/lib/createPopper.js", "../../node_modules/@popperjs/core/lib/popper.js", "../../node_modules/tippy.js/src/constants.ts", "../../node_modules/tippy.js/src/utils.ts", "../../node_modules/tippy.js/src/dom-utils.ts", "../../node_modules/tippy.js/src/bindGlobalEventListeners.ts", "../../node_modules/tippy.js/src/browser.ts", "../../node_modules/tippy.js/src/validation.ts", "../../node_modules/tippy.js/src/props.ts", "../../node_modules/tippy.js/src/template.ts", "../../node_modules/tippy.js/src/createTippy.ts", "../../node_modules/tippy.js/src/index.ts", "../../node_modules/tippy.js/src/addons/createSingleton.ts", "../../node_modules/tippy.js/src/addons/delegate.ts", "../../node_modules/tippy.js/src/plugins/animateFill.ts", "../../node_modules/tippy.js/src/plugins/followCursor.ts", "../../node_modules/tippy.js/src/plugins/inlinePositioning.ts", "../../node_modules/tippy.js/src/plugins/sticky.ts", "../../node_modules/tippy.js/build/base.js", "../../node_modules/text-field-edit/index.js", "../../node_modules/@ungap/structured-clone/esm/deserialize.js", "../../node_modules/@ungap/structured-clone/esm/serialize.js", "../../node_modules/@ungap/structured-clone/esm/index.js", "../../node_modules/bail/index.js", "../../node_modules/unified/node_modules/is-plain-obj/index.js", "../../node_modules/trough/index.js", "../../node_modules/unified/node_modules/unist-util-stringify-position/lib/index.js", "../../node_modules/unified/node_modules/vfile-message/lib/index.js", "../../node_modules/unified/node_modules/vfile/lib/minpath.browser.js", "../../node_modules/unified/node_modules/vfile/lib/minproc.browser.js", "../../node_modules/unified/node_modules/vfile/lib/minurl.shared.js", "../../node_modules/unified/node_modules/vfile/lib/minurl.browser.js", "../../node_modules/unified/node_modules/vfile/lib/index.js", "../../node_modules/unified/lib/callable-instance.js", "../../node_modules/unified/lib/index.js", "../../node_modules/property-information/lib/util/schema.js", "../../node_modules/property-information/lib/util/merge.js", "../../node_modules/property-information/lib/normalize.js", "../../node_modules/property-information/lib/util/info.js", "../../node_modules/property-information/lib/util/types.js", "../../node_modules/property-information/lib/util/defined-info.js", "../../node_modules/property-information/lib/util/create.js", "../../node_modules/property-information/lib/xlink.js", "../../node_modules/property-information/lib/xml.js", "../../node_modules/property-information/lib/util/case-sensitive-transform.js", "../../node_modules/property-information/lib/util/case-insensitive-transform.js", "../../node_modules/property-information/lib/xmlns.js", "../../node_modules/property-information/lib/aria.js", "../../node_modules/property-information/lib/html.js", "../../node_modules/property-information/lib/svg.js", "../../node_modules/property-information/lib/find.js", "../../node_modules/property-information/index.js", "../../node_modules/comma-separated-tokens/index.js", "../../node_modules/rehype-parse/node_modules/hast-util-parse-selector/lib/index.js", "../../node_modules/space-separated-tokens/index.js", "../../node_modules/rehype-parse/node_modules/hastscript/lib/create-h.js", "../../node_modules/rehype-parse/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js", "../../node_modules/rehype-parse/node_modules/hastscript/lib/index.js", "../../node_modules/rehype-parse/node_modules/vfile-location/lib/index.js", "../../node_modules/web-namespaces/index.js", "../../node_modules/rehype-parse/node_modules/hast-util-from-parse5/lib/index.js", "../../node_modules/parse5/dist/common/unicode.js", "../../node_modules/parse5/dist/common/error-codes.js", "../../node_modules/parse5/dist/tokenizer/preprocessor.js", "../../node_modules/parse5/dist/common/token.js", "../../node_modules/entities/lib/esm/generated/generated/decode-data-html.ts", "../../node_modules/entities/lib/esm/generated/generated/decode-data-xml.ts", "../../node_modules/entities/lib/esm/decode_codepoint.ts", "../../node_modules/entities/lib/esm/decode.ts", "../../node_modules/parse5/dist/common/html.js", "../../node_modules/parse5/dist/tokenizer/index.js", "../../node_modules/parse5/dist/parser/open-element-stack.js", "../../node_modules/parse5/dist/parser/formatting-element-list.js", "../../node_modules/parse5/dist/tree-adapters/default.js", "../../node_modules/parse5/dist/common/doctype.js", "../../node_modules/parse5/dist/common/foreign-content.js", "../../node_modules/parse5/dist/parser/index.js", "../../node_modules/entities/lib/esm/escape.ts", "../../node_modules/parse5/dist/serializer/index.js", "../../node_modules/parse5/dist/index.js", "../../node_modules/rehype-parse/node_modules/unist-util-stringify-position/lib/index.js", "../../node_modules/rehype-parse/node_modules/vfile-message/lib/index.js", "../../node_modules/rehype-parse/node_modules/vfile/lib/minpath.browser.js", "../../node_modules/rehype-parse/node_modules/vfile/lib/minproc.browser.js", "../../node_modules/rehype-parse/node_modules/vfile/lib/minurl.shared.js", "../../node_modules/rehype-parse/node_modules/vfile/lib/minurl.browser.js", "../../node_modules/rehype-parse/node_modules/vfile/lib/index.js", "../../node_modules/rehype-parse/node_modules/hast-util-from-html/lib/errors.js", "../../node_modules/rehype-parse/node_modules/hast-util-from-html/lib/index.js", "../../node_modules/rehype-parse/lib/index.js", "../../node_modules/hast-util-embedded/node_modules/hast-util-is-element/lib/index.js", "../../node_modules/hast-util-embedded/lib/index.js", "../../node_modules/rehype-minify-whitespace/node_modules/hast-util-is-element/lib/index.js", "../../node_modules/hast-util-whitespace/lib/index.js", "../../node_modules/rehype-minify-whitespace/node_modules/unist-util-is/lib/index.js", "../../node_modules/rehype-minify-whitespace/lib/block.js", "../../node_modules/rehype-minify-whitespace/lib/content.js", "../../node_modules/rehype-minify-whitespace/lib/skippable.js", "../../node_modules/rehype-minify-whitespace/lib/index.js", "../../node_modules/unist-util-visit/node_modules/unist-util-is/lib/index.js", "../../node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/index.js", "../../node_modules/unist-util-visit/lib/index.js", "../../node_modules/hast-util-to-mdast/node_modules/unist-util-position/lib/index.js", "../../node_modules/hast-util-to-mdast/lib/handlers/a.js", "../../node_modules/hast-util-to-mdast/lib/handlers/base.js", "../../node_modules/hast-util-to-mdast/lib/handlers/blockquote.js", "../../node_modules/hast-util-to-mdast/lib/handlers/br.js", "../../node_modules/hast-util-to-mdast/node_modules/unist-util-is/lib/index.js", "../../node_modules/hast-util-to-mdast/node_modules/unist-util-find-after/lib/index.js", "../../node_modules/hast-util-to-mdast/node_modules/hast-util-is-element/lib/index.js", "../../node_modules/hast-util-to-mdast/node_modules/hast-util-to-text/lib/index.js", "../../node_modules/trim-trailing-lines/index.js", "../../node_modules/hast-util-to-mdast/lib/handlers/code.js", "../../node_modules/hast-util-to-mdast/lib/handlers/comment.js", "../../node_modules/hast-util-to-mdast/lib/handlers/del.js", "../../node_modules/hast-util-to-mdast/lib/util/list-items-spread.js", "../../node_modules/hast-util-to-mdast/lib/handlers/dl.js", "../../node_modules/hast-util-to-mdast/lib/handlers/em.js", "../../node_modules/hast-util-to-mdast/lib/handlers/heading.js", "../../node_modules/hast-util-to-mdast/lib/handlers/hr.js", "../../node_modules/hast-util-to-mdast/lib/handlers/iframe.js", "../../node_modules/hast-util-to-mdast/lib/handlers/img.js", "../../node_modules/hast-util-to-mdast/lib/handlers/inline-code.js", "../../node_modules/hast-util-to-mdast/lib/util/find-selected-options.js", "../../node_modules/hast-util-to-mdast/lib/handlers/input.js", "../../node_modules/hast-util-has-property/lib/index.js", "../../node_modules/hast-util-is-body-ok-link/lib/index.js", "../../node_modules/hast-util-phrasing/node_modules/hast-util-is-element/lib/index.js", "../../node_modules/hast-util-phrasing/lib/index.js", "../../node_modules/hast-util-to-mdast/lib/handlers/li.js", "../../node_modules/hast-util-to-mdast/lib/handlers/list.js", "../../node_modules/hast-util-to-mdast/node_modules/mdast-util-to-string/lib/index.js", "../../node_modules/hast-util-to-mdast/node_modules/mdast-util-phrasing/lib/index.js", "../../node_modules/hast-util-to-mdast/lib/util/wrap.js", "../../node_modules/hast-util-to-mdast/lib/handlers/media.js", "../../node_modules/hast-util-to-mdast/lib/handlers/p.js", "../../node_modules/hast-util-to-mdast/lib/handlers/q.js", "../../node_modules/hast-util-to-mdast/lib/handlers/root.js", "../../node_modules/hast-util-to-mdast/lib/handlers/select.js", "../../node_modules/hast-util-to-mdast/lib/handlers/strong.js", "../../node_modules/hast-util-to-mdast/lib/handlers/table-cell.js", "../../node_modules/hast-util-to-mdast/lib/handlers/table-row.js", "../../node_modules/hast-util-to-mdast/lib/handlers/table.js", "../../node_modules/hast-util-to-mdast/lib/handlers/text.js", "../../node_modules/hast-util-to-mdast/lib/handlers/textarea.js", "../../node_modules/hast-util-to-mdast/lib/handlers/wbr.js", "../../node_modules/hast-util-to-mdast/lib/handlers/index.js", "../../node_modules/hast-util-to-mdast/lib/state.js", "../../node_modules/hast-util-to-mdast/lib/index.js", "../../node_modules/rehype-remark/lib/index.js", "../../node_modules/micromark-util-chunked/index.js", "../../node_modules/micromark-util-combine-extensions/index.js", "../../node_modules/micromark-util-character/lib/unicode-punctuation-regex.js", "../../node_modules/micromark-util-character/index.js", "../../node_modules/micromark-extension-gfm-autolink-literal/lib/syntax.js", "../../node_modules/micromark-util-classify-character/index.js", "../../node_modules/micromark-util-resolve-all/index.js", "../../node_modules/micromark-factory-space/index.js", "../../node_modules/micromark-core-commonmark/lib/blank-line.js", "../../node_modules/decode-named-character-reference/index.dom.js", "../../node_modules/micromark-util-normalize-identifier/index.js", "../../node_modules/micromark-extension-gfm-footnote/lib/syntax.js", "../../node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js", "../../node_modules/micromark-extension-gfm-table/lib/syntax.js", "../../node_modules/micromark-extension-gfm-task-list-item/lib/syntax.js", "../../node_modules/micromark-extension-gfm/index.js", "../../node_modules/ccount/index.js", "../../node_modules/escape-string-regexp/index.js", "../../node_modules/unist-util-is/index.js", "../../node_modules/unist-util-visit-parents/index.js", "../../node_modules/mdast-util-find-and-replace/lib/index.js", "../../node_modules/mdast-util-gfm-autolink-literal/index.js", "../../node_modules/micromark-util-decode-numeric-character-reference/index.js", "../../node_modules/micromark-util-decode-string/index.js", "../../node_modules/mdast-util-to-markdown/lib/util/association.js", "../../node_modules/mdast-util-to-markdown/lib/util/container-flow.js", "../../node_modules/mdast-util-to-markdown/lib/util/indent-lines.js", "../../node_modules/mdast-util-to-markdown/lib/util/pattern-compile.js", "../../node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js", "../../node_modules/mdast-util-to-markdown/lib/util/safe.js", "../../node_modules/mdast-util-to-markdown/lib/util/track.js", "../../node_modules/mdast-util-gfm-footnote/index.js", "../../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js", "../../node_modules/mdast-util-gfm-strikethrough/index.js", "../../node_modules/mdast-util-to-markdown/lib/handle/inline-code.js", "../../node_modules/markdown-table/index.js", "../../node_modules/mdast-util-gfm-table/lib/index.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-bullet.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js", "../../node_modules/mdast-util-to-markdown/lib/handle/list-item.js", "../../node_modules/mdast-util-gfm-task-list-item/index.js", "../../node_modules/mdast-util-gfm/lib/index.js", "../../node_modules/remark-gfm/index.js", "../../node_modules/zwitch/index.js", "../../node_modules/mdast-util-to-markdown/lib/configure.js", "../../node_modules/mdast-util-to-markdown/lib/handle/blockquote.js", "../../node_modules/mdast-util-to-markdown/lib/handle/break.js", "../../node_modules/longest-streak/index.js", "../../node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-fence.js", "../../node_modules/mdast-util-to-markdown/lib/handle/code.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-quote.js", "../../node_modules/mdast-util-to-markdown/lib/handle/definition.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js", "../../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js", "../../node_modules/mdast-util-to-markdown/node_modules/unist-util-visit/lib/index.js", "../../node_modules/mdast-util-to-string/index.js", "../../node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js", "../../node_modules/mdast-util-to-markdown/lib/handle/heading.js", "../../node_modules/mdast-util-to-markdown/lib/handle/html.js", "../../node_modules/mdast-util-to-markdown/lib/handle/image.js", "../../node_modules/mdast-util-to-markdown/lib/handle/image-reference.js", "../../node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js", "../../node_modules/mdast-util-to-markdown/lib/handle/link.js", "../../node_modules/mdast-util-to-markdown/lib/handle/link-reference.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered-other.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-rule.js", "../../node_modules/mdast-util-to-markdown/lib/handle/list.js", "../../node_modules/mdast-util-to-markdown/lib/handle/paragraph.js", "../../node_modules/mdast-util-phrasing/index.js", "../../node_modules/mdast-util-to-markdown/lib/handle/root.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-strong.js", "../../node_modules/mdast-util-to-markdown/lib/handle/strong.js", "../../node_modules/mdast-util-to-markdown/lib/handle/text.js", "../../node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js", "../../node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js", "../../node_modules/mdast-util-to-markdown/lib/handle/index.js", "../../node_modules/mdast-util-to-markdown/lib/join.js", "../../node_modules/mdast-util-to-markdown/lib/unsafe.js", "../../node_modules/mdast-util-to-markdown/lib/index.js", "../../node_modules/remark-stringify/lib/index.js", "../../static/leafac--javascript.mjs"],
"sourcesContent": ["/*global define:false */\n/**\n * Copyright 2012-2017 Craig Campbell\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * Mousetrap is a simple keyboard shortcut library for Javascript with\n * no external dependencies\n *\n * @version 1.6.5\n * @url craig.is/killing/mice\n */\n(function(window, document, undefined) {\n\n // Check if mousetrap is used inside browser, if not, return\n if (!window) {\n return;\n }\n\n /**\n * mapping of special keycodes to their corresponding keys\n *\n * everything in this dictionary cannot use keypress events\n * so it has to be here to map to the correct keycodes for\n * keyup/keydown events\n *\n * @type {Object}\n */\n var _MAP = {\n 8: 'backspace',\n 9: 'tab',\n 13: 'enter',\n 16: 'shift',\n 17: 'ctrl',\n 18: 'alt',\n 20: 'capslock',\n 27: 'esc',\n 32: 'space',\n 33: 'pageup',\n 34: 'pagedown',\n 35: 'end',\n 36: 'home',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down',\n 45: 'ins',\n 46: 'del',\n 91: 'meta',\n 93: 'meta',\n 224: 'meta'\n };\n\n /**\n * mapping for special characters so they can support\n *\n * this dictionary is only used incase you want to bind a\n * keyup or keydown event to one of these keys\n *\n * @type {Object}\n */\n var _KEYCODE_MAP = {\n 106: '*',\n 107: '+',\n 109: '-',\n 110: '.',\n 111 : '/',\n 186: ';',\n 187: '=',\n 188: ',',\n 189: '-',\n 190: '.',\n 191: '/',\n 192: '`',\n 219: '[',\n 220: '\\\\',\n 221: ']',\n 222: '\\''\n };\n\n /**\n * this is a mapping of keys that require shift on a US keypad\n * back to the non shift equivelents\n *\n * this is so you can use keyup events with these keys\n *\n * note that this will only work reliably on US keyboards\n *\n * @type {Object}\n */\n var _SHIFT_MAP = {\n '~': '`',\n '!': '1',\n '@': '2',\n '#': '3',\n '$': '4',\n '%': '5',\n '^': '6',\n '&': '7',\n '*': '8',\n '(': '9',\n ')': '0',\n '_': '-',\n '+': '=',\n ':': ';',\n '\\\"': '\\'',\n '<': ',',\n '>': '.',\n '?': '/',\n '|': '\\\\'\n };\n\n /**\n * this is a list of special strings you can use to map\n * to modifier keys when you specify your keyboard shortcuts\n *\n * @type {Object}\n */\n var _SPECIAL_ALIASES = {\n 'option': 'alt',\n 'command': 'meta',\n 'return': 'enter',\n 'escape': 'esc',\n 'plus': '+',\n 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'\n };\n\n /**\n * variable to store the flipped version of _MAP from above\n * needed to check if we should use keypress or not when no action\n * is specified\n *\n * @type {Object|undefined}\n */\n var _REVERSE_MAP;\n\n /**\n * loop through the f keys, f1 to f19 and add them to the map\n * programatically\n */\n for (var i = 1; i < 20; ++i) {\n _MAP[111 + i] = 'f' + i;\n }\n\n /**\n * loop through to map numbers on the numeric keypad\n */\n for (i = 0; i <= 9; ++i) {\n\n // This needs to use a string cause otherwise since 0 is falsey\n // mousetrap will never fire for numpad 0 pressed as part of a keydown\n // event.\n //\n // @see https://github.com/ccampbell/mousetrap/pull/258\n _MAP[i + 96] = i.toString();\n }\n\n /**\n * cross browser add event method\n *\n * @param {Element|HTMLDocument} object\n * @param {string} type\n * @param {Function} callback\n * @returns void\n */\n function _addEvent(object, type, callback) {\n if (object.addEventListener) {\n object.addEventListener(type, callback, false);\n return;\n }\n\n object.attachEvent('on' + type, callback);\n }\n\n /**\n * takes the event and returns the key character\n *\n * @param {Event} e\n * @return {string}\n */\n function _characterFromEvent(e) {\n\n // for keypress events we should return the character as is\n if (e.type == 'keypress') {\n var character = String.fromCharCode(e.which);\n\n // if the shift key is not pressed then it is safe to assume\n // that we want the character to be lowercase. this means if\n // you accidentally have caps lock on then your key bindings\n // will continue to work\n //\n // the only side effect that might not be desired is if you\n // bind something like 'A' cause you want to trigger an\n // event when capital A is pressed caps lock will no longer\n // trigger the event. shift+a will though.\n if (!e.shiftKey) {\n character = character.toLowerCase();\n }\n\n return character;\n }\n\n // for non keypress events the special maps are needed\n if (_MAP[e.which]) {\n return _MAP[e.which];\n }\n\n if (_KEYCODE_MAP[e.which]) {\n return _KEYCODE_MAP[e.which];\n }\n\n // if it is not in the special map\n\n // with keydown and keyup events the character seems to always\n // come in as an uppercase character whether you are pressing shift\n // or not. we should make sure it is always lowercase for comparisons\n return String.fromCharCode(e.which).toLowerCase();\n }\n\n /**\n * checks if two arrays are equal\n *\n * @param {Array} modifiers1\n * @param {Array} modifiers2\n * @returns {boolean}\n */\n function _modifiersMatch(modifiers1, modifiers2) {\n return modifiers1.sort().join(',') === modifiers2.sort().join(',');\n }\n\n /**\n * takes a key event and figures out what the modifiers are\n *\n * @param {Event} e\n * @returns {Array}\n */\n function _eventModifiers(e) {\n var modifiers = [];\n\n if (e.shiftKey) {\n modifiers.push('shift');\n }\n\n if (e.altKey) {\n modifiers.push('alt');\n }\n\n if (e.ctrlKey) {\n modifiers.push('ctrl');\n }\n\n if (e.metaKey) {\n modifiers.push('meta');\n }\n\n return modifiers;\n }\n\n /**\n * prevents default for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _preventDefault(e) {\n if (e.preventDefault) {\n e.preventDefault();\n return;\n }\n\n e.returnValue = false;\n }\n\n /**\n * stops propogation for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _stopPropagation(e) {\n if (e.stopPropagation) {\n e.stopPropagation();\n return;\n }\n\n e.cancelBubble = true;\n }\n\n /**\n * determines if the keycode specified is a modifier key or not\n *\n * @param {string} key\n * @returns {boolean}\n */\n function _isModifier(key) {\n return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';\n }\n\n /**\n * reverses the map lookup so that we can look for specific keys\n * to see what can and can't use keypress\n *\n * @return {Object}\n */\n function _getReverseMap() {\n if (!_REVERSE_MAP) {\n _REVERSE_MAP = {};\n for (var key in _MAP) {\n\n // pull out the numeric keypad from here cause keypress should\n // be able to detect the keys from the character\n if (key > 95 && key < 112) {\n continue;\n }\n\n if (_MAP.hasOwnProperty(key)) {\n _REVERSE_MAP[_MAP[key]] = key;\n }\n }\n }\n return _REVERSE_MAP;\n }\n\n /**\n * picks the best action based on the key combination\n *\n * @param {string} key - character for key\n * @param {Array} modifiers\n * @param {string=} action passed in\n */\n function _pickBestAction(key, modifiers, action) {\n\n // if no action was picked in we should try to pick the one\n // that we think would work best for this key\n if (!action) {\n action = _getReverseMap()[key] ? 'keydown' : 'keypress';\n }\n\n // modifier keys don't work as expected with keypress,\n // switch to keydown\n if (action == 'keypress' && modifiers.length) {\n action = 'keydown';\n }\n\n return action;\n }\n\n /**\n * Converts from a string key combination to an array\n *\n * @param {string} combination like \"command+shift+l\"\n * @return {Array}\n */\n function _keysFromString(combination) {\n if (combination === '+') {\n return ['+'];\n }\n\n combination = combination.replace(/\\+{2}/g, '+plus');\n return combination.split('+');\n }\n\n /**\n * Gets info for a specific key combination\n *\n * @param {string} combination key combination (\"command+s\" or \"a\" or \"*\")\n * @param {string=} action\n * @returns {Object}\n */\n function _getKeyInfo(combination, action) {\n var keys;\n var key;\n var i;\n var modifiers = [];\n\n // take the keys from this pattern and figure out what the actual\n // pattern is all about\n keys = _keysFromString(combination);\n\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n\n // normalize key names\n if (_SPECIAL_ALIASES[key]) {\n key = _SPECIAL_ALIASES[key];\n }\n\n // if this is not a keypress event then we should\n // be smart about using shift keys\n // this will only work for US keyboards however\n if (action && action != 'keypress' && _SHIFT_MAP[key]) {\n key = _SHIFT_MAP[key];\n modifiers.push('shift');\n }\n\n // if this key is a modifier then add it to the list of modifiers\n if (_isModifier(key)) {\n modifiers.push(key);\n }\n }\n\n // depending on what the key combination is\n // we will try to pick the best event for it\n action = _pickBestAction(key, modifiers, action);\n\n return {\n key: key,\n modifiers: modifiers,\n action: action\n };\n }\n\n function _belongsTo(element, ancestor) {\n if (element === null || element === document) {\n return false;\n }\n\n if (element === ancestor) {\n return true;\n }\n\n return _belongsTo(element.parentNode, ancestor);\n }\n\n function Mousetrap(targetElement) {\n var self = this;\n\n targetElement = targetElement || document;\n\n if (!(self instanceof Mousetrap)) {\n return new Mousetrap(targetElement);\n }\n\n /**\n * element to attach key events to\n *\n * @type {Element}\n */\n self.target = targetElement;\n\n /**\n * a list of all the callbacks setup via Mousetrap.bind()\n *\n * @type {Object}\n */\n self._callbacks = {};\n\n /**\n * direct map of string combinations to callbacks used for trigger()\n *\n * @type {Object}\n */\n self._directMap = {};\n\n /**\n * keeps track of what level each sequence is at since multiple\n * sequences can start out with the same sequence\n *\n * @type {Object}\n */\n var _sequenceLevels = {};\n\n /**\n * variable to store the setTimeout call\n *\n * @type {null|number}\n */\n var _resetTimer;\n\n /**\n * temporary state where we will ignore the next keyup\n *\n * @type {boolean|string}\n */\n var _ignoreNextKeyup = false;\n\n /**\n * temporary state where we will ignore the next keypress\n *\n * @type {boolean}\n */\n var _ignoreNextKeypress = false;\n\n /**\n * are we currently inside of a sequence?\n * type of action (\"keyup\" or \"keydown\" or \"keypress\") or false\n *\n * @type {boolean|string}\n */\n var _nextExpectedAction = false;\n\n /**\n * resets all sequence counters except for the ones passed in\n *\n * @param {Object} doNotReset\n * @returns void\n */\n function _resetSequences(doNotReset) {\n doNotReset = doNotReset || {};\n\n var activeSequences = false,\n key;\n\n for (key in _sequenceLevels) {\n if (doNotReset[key]) {\n activeSequences = true;\n continue;\n }\n _sequenceLevels[key] = 0;\n }\n\n if (!activeSequences) {\n _nextExpectedAction = false;\n }\n }\n\n /**\n * finds all callbacks that match based on the keycode, modifiers,\n * and action\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event|Object} e\n * @param {string=} sequenceName - name of the sequence we are looking for\n * @param {string=} combination\n * @param {number=} level\n * @returns {Array}\n */\n function _getMatches(character, modifiers, e, sequenceName, combination, level) {\n var i;\n var callback;\n var matches = [];\n var action = e.type;\n\n // if there are no events related to this keycode\n if (!self._callbacks[character]) {\n return [];\n }\n\n // if a modifier key is coming up on its own we should allow it\n if (action == 'keyup' && _isModifier(character)) {\n modifiers = [character];\n }\n\n // loop through all callbacks for the key that was pressed\n // and see if any of them match\n for (i = 0; i < self._callbacks[character].length; ++i) {\n callback = self._callbacks[character][i];\n\n // if a sequence name is not specified, but this is a sequence at\n // the wrong level then move onto the next match\n if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {\n continue;\n }\n\n // if the action we are looking for doesn't match the action we got\n // then we should keep going\n if (action != callback.action) {\n continue;\n }\n\n // if this is a keypress event and the meta key and control key\n // are not pressed that means that we need to only look at the\n // character, otherwise check the modifiers as well\n //\n // chrome will not fire a keypress if meta or control is down\n // safari will fire a keypress if meta or meta+shift is down\n // firefox will fire a keypress if meta or control is down\n if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {\n\n // when you bind a combination or sequence a second time it\n // should overwrite the first one. if a sequenceName or\n // combination is specified in this call it does just that\n //\n // @todo make deleting its own method?\n var deleteCombo = !sequenceName && callback.combo == combination;\n var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;\n if (deleteCombo || deleteSequence) {\n self._callbacks[character].splice(i, 1);\n }\n\n matches.push(callback);\n }\n }\n\n return matches;\n }\n\n /**\n * actually calls the callback function\n *\n * if your callback function returns false this will use the jquery\n * convention - prevent default and stop propogation on the event\n *\n * @param {Function} callback\n * @param {Event} e\n * @returns void\n */\n function _fireCallback(callback, e, combo, sequence) {\n\n // if this event should not happen stop here\n if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {\n return;\n }\n\n if (callback(e, combo) === false) {\n _preventDefault(e);\n _stopPropagation(e);\n }\n }\n\n /**\n * handles a character key event\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event} e\n * @returns void\n */\n self._handleKey = function(character, modifiers, e) {\n var callbacks = _getMatches(character, modifiers, e);\n var i;\n var doNotReset = {};\n var maxLevel = 0;\n var processedSequenceCallback = false;\n\n // Calculate the maxLevel for sequences so we can only execute the longest callback sequence\n for (i = 0; i < callbacks.length; ++i) {\n if (callbacks[i].seq) {\n maxLevel = Math.max(maxLevel, callbacks[i].level);\n }\n }\n\n // loop through matching callbacks for this key event\n for (i = 0; i < callbacks.length; ++i) {\n\n // fire for all sequence callbacks\n // this is because if for example you have multiple sequences\n // bound such as \"g i\" and \"g t\" they both need to fire the\n // callback for matching g cause otherwise you can only ever\n // match the first one\n if (callbacks[i].seq) {\n\n // only fire callbacks for the maxLevel to prevent\n // subsequences from also firing\n //\n // for example 'a option b' should not cause 'option b' to fire\n // even though 'option b' is part of the other sequence\n //\n // any sequences that do not match here will be discarded\n // below by the _resetSequences call\n if (callbacks[i].level != maxLevel) {\n continue;\n }\n\n processedSequenceCallback = true;\n\n // keep a list of which sequences were matches for later\n doNotReset[callbacks[i].seq] = 1;\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);\n continue;\n }\n\n // if there were no sequence matches but we are still here\n // that means this is a regular match so we should fire that\n if (!processedSequenceCallback) {\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo);\n }\n }\n\n // if the key you pressed matches the type of sequence without\n // being a modifier (ie \"keyup\" or \"keypress\") then we should\n // reset all sequences that were not matched by this event\n //\n // this is so, for example, if you have the sequence \"h a t\" and you\n // type \"h e a r t\" it does not match. in this case the \"e\" will\n // cause the sequence to reset\n //\n // modifier keys are ignored because you can have a sequence\n // that contains modifiers such as \"enter ctrl+space\" and in most\n // cases the modifier key will be pressed before the next key\n //\n // also if you have a sequence such as \"ctrl+b a\" then pressing the\n // \"b\" key will trigger a \"keypress\" and a \"keydown\"\n //\n // the \"keydown\" is expected when there is a modifier, but the\n // \"keypress\" ends up matching the _nextExpectedAction since it occurs\n // after and that causes the sequence to reset\n //\n // we ignore keypresses in a sequence that directly follow a keydown\n // for the same character\n var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;\n if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {\n _resetSequences(doNotReset);\n }\n\n _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';\n };\n\n /**\n * handles a keydown event\n *\n * @param {Event} e\n * @returns void\n */\n function _handleKeyEvent(e) {\n\n // normalize e.which for key events\n // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion\n if (typeof e.which !== 'number') {\n e.which = e.keyCode;\n }\n\n var character = _characterFromEvent(e);\n\n // no character found then stop\n if (!character) {\n return;\n }\n\n // need to use === for the character check because the character can be 0\n if (e.type == 'keyup' && _ignoreNextKeyup === character) {\n _ignoreNextKeyup = false;\n return;\n }\n\n self.handleKey(character, _eventModifiers(e), e);\n }\n\n /**\n * called to set a 1 second timeout on the specified sequence\n *\n * this is so after each key press in the sequence you have 1 second\n * to press the next key before you have to start over\n *\n * @returns void\n */\n function _resetSequenceTimer() {\n clearTimeout(_resetTimer);\n _resetTimer = setTimeout(_resetSequences, 1000);\n }\n\n /**\n * binds a key sequence to an event\n *\n * @param {string} combo - combo specified in bind call\n * @param {Array} keys\n * @param {Function} callback\n * @param {string=} action\n * @returns void\n */\n function _bindSequence(combo, keys, callback, action) {\n\n // start off by adding a sequence level record for this combination\n // and setting the level to 0\n _sequenceLevels[combo] = 0;\n\n /**\n * callback to increase the sequence level for this sequence and reset\n * all other sequences that were active\n *\n * @param {string} nextAction\n * @returns {Function}\n */\n function _increaseSequence(nextAction) {\n return function() {\n _nextExpectedAction = nextAction;\n ++_sequenceLevels[combo];\n _resetSequenceTimer();\n };\n }\n\n /**\n * wraps the specified callback inside of another function in order\n * to reset all sequence counters as soon as this sequence is done\n *\n * @param {Event} e\n * @returns void\n */\n function _callbackAndReset(e) {\n _fireCallback(callback, e, combo);\n\n // we should ignore the next key up if the action is key down\n // or keypress. this is so if you finish a sequence and\n // release the key the final key will not trigger a keyup\n if (action !== 'keyup') {\n _ignoreNextKeyup = _characterFromEvent(e);\n }\n\n // weird race condition if a sequence ends with the key\n // another sequence begins with\n setTimeout(_resetSequences, 10);\n }\n\n // loop through keys one at a time and bind the appropriate callback\n // function. for any key leading up to the final one it should\n // increase the sequence. after the final, it should reset all sequences\n //\n // if an action is specified in the original bind call then that will\n // be used throughout. otherwise we will pass the action that the\n // next key in the sequence should match. this allows a sequence\n // to mix and match keypress and keydown events depending on which\n // ones are better suited to the key provided\n for (var i = 0; i < keys.length; ++i) {\n var isFinal = i + 1 === keys.length;\n var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);\n _bindSingle(keys[i], wrappedCallback, action, combo, i);\n }\n }\n\n /**\n * binds a single keyboard combination\n *\n * @param {string} combination\n * @param {Function} callback\n * @param {string=} action\n * @param {string=} sequenceName - name of sequence if part of sequence\n * @param {number=} level - what part of the sequence the command is\n * @returns void\n */\n function _bindSingle(combination, callback, action, sequenceName, level) {\n\n // store a direct mapped reference for use with Mousetrap.trigger\n self._directMap[combination + ':' + action] = callback;\n\n // make sure multiple spaces in a row become a single space\n combination = combination.replace(/\\s+/g, ' ');\n\n var sequence = combination.split(' ');\n var info;\n\n // if this pattern is a sequence of keys then run through this method\n // to reprocess each pattern one key at a time\n if (sequence.length > 1) {\n _bindSequence(combination, sequence, callback, action);\n return;\n }\n\n info = _getKeyInfo(combination, action);\n\n // make sure to initialize array if this is the first time\n // a callback is added for this key\n self._callbacks[info.key] = self._callbacks[info.key] || [];\n\n // remove an existing match if there is one\n _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);\n\n // add this call back to the array\n // if it is a sequence put it at the beginning\n // if not put it at the end\n //\n // this is important because the way these are processed expects\n // the sequence ones to come first\n self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({\n callback: callback,\n modifiers: info.modifiers,\n action: info.action,\n seq: sequenceName,\n level: level,\n combo: combination\n });\n }\n\n /**\n * binds multiple combinations to the same callback\n *\n * @param {Array} combinations\n * @param {Function} callback\n * @param {string|undefined} action\n * @returns void\n */\n self._bindMultiple = function(combinations, callback, action) {\n for (var i = 0; i < combinations.length; ++i) {\n _bindSingle(combinations[i], callback, action);\n }\n };\n\n // start!\n _addEvent(targetElement, 'keypress', _handleKeyEvent);\n _addEvent(targetElement, 'keydown', _handleKeyEvent);\n _addEvent(targetElement, 'keyup', _handleKeyEvent);\n }\n\n /**\n * binds an event to mousetrap\n *\n * can be a single key, a combination of keys separated with +,\n * an array of keys, or a sequence of keys separated by spaces\n *\n * be sure to list the modifier keys first to make sure that the\n * correct key ends up getting bound (the last key in the pattern)\n *\n * @param {string|Array} keys\n * @param {Function} callback\n * @param {string=} action - 'keypress', 'keydown', or 'keyup'\n * @returns void\n */\n Mousetrap.prototype.bind = function(keys, callback, action) {\n var self = this;\n keys = keys instanceof Array ? keys : [keys];\n self._bindMultiple.call(self, keys, callback, action);\n return self;\n };\n\n /**\n * unbinds an event to mousetrap\n *\n * the unbinding sets the callback function of the specified key combo\n * to an empty function and deletes the corresponding key in the\n * _directMap dict.\n *\n * TODO: actually remove this from the _callbacks dictionary instead\n * of binding an empty function\n *\n * the keycombo+action has to be exactly the same as\n * it was defined in the bind method\n *\n * @param {string|Array} keys\n * @param {string} action\n * @returns void\n */\n Mousetrap.prototype.unbind = function(keys, action) {\n var self = this;\n return self.bind.call(self, keys, function() {}, action);\n };\n\n /**\n * triggers an event that has already been bound\n *\n * @param {string} keys\n * @param {string=} action\n * @returns void\n */\n Mousetrap.prototype.trigger = function(keys, action) {\n var self = this;\n if (self._directMap[keys + ':' + action]) {\n self._directMap[keys + ':' + action]({}, keys);\n }\n return self;\n };\n\n /**\n * resets the library back to its initial state. this is useful\n * if you want to clear out the current keyboard shortcuts and bind\n * new ones - for example if you switch to another page\n *\n * @returns void\n */\n Mousetrap.prototype.reset = function() {\n var self = this;\n self._callbacks = {};\n self._directMap = {};\n return self;\n };\n\n /**\n * should we stop this event before firing off callbacks\n *\n * @param {Event} e\n * @param {Element} element\n * @return {boolean}\n */\n Mousetrap.prototype.stopCallback = function(e, element) {\n var self = this;\n\n // if the element has the class \"mousetrap\" then no need to stop\n if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {\n return false;\n }\n\n if (_belongsTo(element, self.target)) {\n return false;\n }\n\n // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,\n // not the initial event target in the shadow tree. Note that not all events cross the\n // shadow boundary.\n // For shadow trees with `mode: 'open'`, the initial event target is the first element in\n // the event\u2019s composed path. For shadow trees with `mode: 'closed'`, the initial event\n // target cannot be obtained.\n if ('composedPath' in e && typeof e.composedPath === 'function') {\n // For open shadow trees, update `element` so that the following check works.\n var initialEventTarget = e.composedPath()[0];\n if (initialEventTarget !== e.target) {\n element = initialEventTarget;\n }\n }\n\n // stop for input, select, and textarea\n return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;\n };\n\n /**\n * exposes _handleKey publicly so it can be overwritten by extensions\n */\n Mousetrap.prototype.handleKey = function() {\n var self = this;\n return self._handleKey.apply(self, arguments);\n };\n\n /**\n * allow custom key mappings\n */\n Mousetrap.addKeycodes = function(object) {\n for (var key in object) {\n if (object.hasOwnProperty(key)) {\n _MAP[key] = object[key];\n }\n }\n _REVERSE_MAP = null;\n };\n\n /**\n * Init the global mousetrap functions\n *\n * This method is needed to allow the global mousetrap functions to work\n * now that mousetrap is a constructor function.\n */\n Mousetrap.init = function() {\n var documentMousetrap = Mousetrap(document);\n for (var method in documentMousetrap) {\n if (method.charAt(0) !== '_') {\n Mousetrap[method] = (function(method) {\n return function() {\n return documentMousetrap[method].apply(documentMousetrap, arguments);\n };\n } (method));\n }\n }\n };\n\n Mousetrap.init();\n\n // expose mousetrap to the global object\n window.Mousetrap = Mousetrap;\n\n // expose as a common js module\n if (typeof module !== 'undefined' && module.exports) {\n module.exports = Mousetrap;\n }\n\n // expose mousetrap as an AMD module\n if (typeof define === 'function' && define.amd) {\n define(function() {\n return Mousetrap;\n });\n }\n}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);\n", "/* jshint browser: true */\n\n(function () {\n\n// We'll copy the properties below into the mirror div.\n// Note that some browsers, such as Firefox, do not concatenate properties\n// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),\n// so we have to list every single property explicitly.\nvar properties = [\n 'direction', // RTL support\n 'boxSizing',\n 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does\n 'height',\n 'overflowX',\n 'overflowY', // copy the scrollbar for IE\n\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderStyle',\n\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration', // might not make a difference, but better be safe\n\n 'letterSpacing',\n 'wordSpacing',\n\n 'tabSize',\n 'MozTabSize'\n\n];\n\nvar isBrowser = (typeof window !== 'undefined');\nvar isFirefox = (isBrowser && window.mozInnerScreenX != null);\n\nfunction getCaretCoordinates(element, position, options) {\n if (!isBrowser) {\n throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');\n }\n\n var debug = options && options.debug || false;\n if (debug) {\n var el = document.querySelector('#input-textarea-caret-position-mirror-div');\n if (el) el.parentNode.removeChild(el);\n }\n\n // The mirror div will replicate the textarea's style\n var div = document.createElement('div');\n div.id = 'input-textarea-caret-position-mirror-div';\n document.body.appendChild(div);\n\n var style = div.style;\n var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9\n var isInput = element.nodeName === 'INPUT';\n\n // Default textarea styles\n style.whiteSpace = 'pre-wrap';\n if (!isInput)\n style.wordWrap = 'break-word'; // only for textarea-s\n\n // Position off-screen\n style.position = 'absolute'; // required to return coordinates properly\n if (!debug)\n style.visibility = 'hidden'; // not 'display: none' because we want rendering\n\n // Transfer the element's properties to the div\n properties.forEach(function (prop) {\n if (isInput && prop === 'lineHeight') {\n // Special case for s because text is rendered centered and line height may be != height\n style.lineHeight = computed.height;\n } else {\n style[prop] = computed[prop];\n }\n });\n\n if (isFirefox) {\n // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll';\n } else {\n style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'\n }\n\n div.textContent = element.value.substring(0, position);\n // The second special handling for input type=\"text\" vs textarea:\n // spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n if (isInput)\n div.textContent = div.textContent.replace(/\\s/g, '\\u00a0');\n\n var span = document.createElement('span');\n // Wrapping must be replicated *exactly*, including when a long word gets\n // onto the next line, with whitespace at the end of the line before (#7).\n // The *only* reliable way to do that is to copy the *entire* rest of the\n // textarea's content into the created at the caret position.\n // For inputs, just '.' would be enough, but no need to bother.\n span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all\n div.appendChild(span);\n\n var coordinates = {\n top: span.offsetTop + parseInt(computed['borderTopWidth']),\n left: span.offsetLeft + parseInt(computed['borderLeftWidth']),\n height: parseInt(computed['lineHeight'])\n };\n\n if (debug) {\n span.style.backgroundColor = '#aaa';\n } else {\n document.body.removeChild(div);\n }\n\n return coordinates;\n}\n\nif (typeof module != 'undefined' && typeof module.exports != 'undefined') {\n module.exports = getCaretCoordinates;\n} else if(isBrowser) {\n window.getCaretCoordinates = getCaretCoordinates;\n}\n\n}());\n", "\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:true});exports.applyPatch=exports.calcPatch=exports.lcs=exports.diff=exports.diff_core=void 0;function diff_internal(state,c){const{b,eq,stack_base}=state;let{i,N,j,M,Z,stack_top}=state;for(;;){switch(c){case 0:{Z_block:while(N>0&&M>0){b.fill(0,0,2*Z);const W=N-M;const L=N+M;const parity=L&1;const offsetx=i+N-1;const offsety=j+M-1;const hmax=(L+parity)/2;let z;h_loop:for(let h=0;h<=hmax;h++){const kmin=2*Math.max(0,h-M)-h;const kmax=h-2*Math.max(0,h-N);for(let k=kmin;k<=kmax;k+=2){const gkm=b[k-1-Z*Math.floor((k-1)/Z)];const gkp=b[k+1-Z*Math.floor((k+1)/Z)];const u=(k===-h||(k!==h&&gkm=1-h&&z=N){if(h>1||x!==u){stack_base[stack_top++]=i+x;stack_base[stack_top++]=N-x;stack_base[stack_top++]=j+y;stack_base[stack_top++]=M-y;N=u;M=v;Z=2*(Math.min(N,M)+1);continue Z_block;}\nelse\nbreak h_loop;}}\nfor(let k=kmin;k<=kmax;k+=2){const pkm=b[Z+k-1-Z*Math.floor((k-1)/Z)];const pkp=b[Z+k+1-Z*Math.floor((k+1)/Z)];const u=(k===-h||(k!==h&&pkm=-h&&z<=h&&x+b[z-Z*Math.floor(z/Z)]>=N){if(h>0||x!==u){stack_base[stack_top++]=i+N-u;stack_base[stack_top++]=u;stack_base[stack_top++]=j+M-v;stack_base[stack_top++]=v;N=N-x;M=M-y;Z=2*(Math.min(N,M)+1);continue Z_block;}\nelse\nbreak h_loop;}}}\nif(N===M)\ncontinue;if(M>N){i+=N;j+=N;M-=N;N=0;}\nelse{i+=M;j+=M;N-=M;M=0;}\nbreak;}\nif(N+M!==0){if(state.pxe===i||state.pye===j){state.pxe=i+N;state.pye=j+M;}\nelse{const sx=state.pxs;state.oxs=state.pxs;state.oxe=state.pxe;state.oys=state.pys;state.oye=state.pye;state.pxs=i;state.pxe=i+N;state.pys=j;state.pye=j+M;if(sx>=0){state.i=i;state.N=N;state.j=j;state.M=M;state.Z=Z;state.stack_top=stack_top;return 1;}}}}\ncase 1:{if(stack_top===0)\nreturn 2;M=stack_base[--stack_top];j=stack_base[--stack_top];N=stack_base[--stack_top];i=stack_base[--stack_top];Z=2*(Math.min(N,M)+1);c=0;}}}}\nclass DiffGen{constructor(state){this.state=state;this.c=0;this.result={value:null,done:false};}\n[Symbol.iterator](){return this;}\nnext(){const{state,result}=this;if(this.c>1){result.done=true;result.value=undefined;return result;}\nconst c=diff_internal(state,this.c);this.c=c;if(c===1){result.value=[state.oxs,state.oxe,state.oys,state.oye];return result;}\nif(state.pxs>=0){result.value=[state.pxs,state.pxe,state.pys,state.pye];return result;}\nresult.done=true;result.value=undefined;return result;}}\nfunction diff_core(i,N,j,M,eq){const Z=(Math.min(N,M)+1)*2;const L=N+M;const b=new(L<256?Uint8Array:L<65536?Uint16Array:Uint32Array)(2*Z);return new DiffGen({i,N,j,M,Z,b,eq,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[],});}\nexports.diff_core=diff_core;function diff(xs,ys,eq){let[i,N,M]=[0,xs.length,ys.length];if(typeof eq==='function'){while(ii&&M>i);}\nelse{while(ii&&M>i);eq=(i,j)=>xs[i]===ys[j];}\nreturn diff_core(i,N+1-i,i,M+1-i,eq);}\nexports.diff=diff;class LCSGen{constructor(diff,N){this.diff=diff;this.N=N;this.i=0;this.j=0;}\n[Symbol.iterator](){return this;}\nnext(){const rec=this.diff.next();if(rec.done){const{i,j,N}=this;if(i0)\nyield ins;i=dele;}\nif(iparseFloat(n.maxHeight)?(\"hidden\"===n.overflowY&&(t.style.overflow=\"scroll\"),i=parseFloat(n.maxHeight)):\"hidden\"!==n.overflowY&&(t.style.overflow=\"hidden\"),t.style.height=i+\"px\",s&&(t.style.textAlign=s),o&&o(),r!==i&&(t.dispatchEvent(new Event(\"autosize:resized\",{bubbles:!0})),r=i),c!==n.overflow&&!s)){var v=n.textAlign;\"hidden\"===n.overflow&&(t.style.textAlign=\"start\"===v?\"end\":\"start\"),a({restoreTextAlign:v,testForHeightReduction:!0})}}function s(){a({testForHeightReduction:!0,restoreTextAlign:null})}}(t)}),t}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],t),e},r.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e});var n=r;export default n;\n", "\n import \"@fontsource-variable/public-sans\";\n import \"@fontsource-variable/public-sans/wght-italic.css\";\n import \"@fontsource-variable/jetbrains-mono\";\n import \"@fontsource-variable/jetbrains-mono/wght-italic.css\";\n import \"bootstrap-icons/font/bootstrap-icons.css\";\n import \"katex/dist/katex.css\";\n import \"tippy.js/dist/tippy.css\";\n import \"tippy.js/dist/svg-arrow.css\";\n import \"tippy.js/dist/border.css\";\n import \"@leafac/css/static/index.css\";\n import \"./index.css\";\n\n import autosize from \"autosize\";\n import Mousetrap from \"mousetrap\";\n import scrollIntoViewIfNeeded from \"scroll-into-view-if-needed\";\n import * as tippy from \"tippy.js\";\n import textareaCaret from \"textarea-caret\";\n import * as textFieldEdit from \"text-field-edit\";\n import { unified } from \"unified\";\n import rehypeParse from \"rehype-parse\";\n import rehypeRemark from \"rehype-remark\";\n import remarkGfm from \"remark-gfm\";\n import remarkStringify from \"remark-stringify\";\n // import * as leafac from \"@leafac/javascript/static/index.mjs\";\n import * as leafac from \"./leafac--javascript.mjs\";\n\n leafac.customFormValidation();\n leafac.warnAboutLosingInputs();\n leafac.tippySetDefaultProps();\n leafac.liveNavigation();\n/********************************************************************************/\n\nleafac.execute.functions.set(\"esiuprnjstllbb\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Sign up on a Courselore installation managed by the developers of Courselore.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fomhgyheydeoig\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Sign in on a Courselore installation managed by the developers of Courselore.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"abtpffrqjnamc\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Join the Courselore community on Meta Courselore, a Courselore course that isn\u2019t really a course, but a place to talk about Courselore itself.\", \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"caxsoypwnzevte\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Courselore is open source and will be free forever for installing on your own server.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gejvgbbmrkzxgm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"A Courselore installation running the latest development version. Not for use with real courses.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gwglhiuerrsnet\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"A straightforward way to make text bold, include links, and so forth.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eosbpprmtycexg\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"A way to write mathematical formulas.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gufpgpiajhfwgk\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Color computer code to make it easier to read.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgyimxunfvfxjj\", function (event) {\n\n this.isModified = false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fstbexzbletcma\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Sign up on a Courselore installation managed by the developers of Courselore.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"deirqharjstubp\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Sign in on a Courselore installation managed by the developers of Courselore.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"doqhttaaydmefk\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Join the Courselore community on Meta Courselore, a Courselore course that isn\u2019t really a course, but a place to talk about Courselore itself.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"vsksmcvsbykxr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Courselore is open source and will be free forever for installing on your own server.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bbnxayksyitxhm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"A Courselore installation running the latest development version. Not for use with real courses.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"zyczawlnqudcv\", function (event) {\n\n this.isModified = false;\n\n this.oninput = () => {\n const filterPhrases = this.value.split(/[^a-z0-9]+/i).filter((filterPhrase) => filterPhrase.trim() !== \"\");\n for (const user of document.querySelectorAll('[key^=\"user/\"]')) {\n let userHidden = filterPhrases.length > 0;\n for (const filterablePhrasesElement of user.querySelectorAll(\"[data-filterable-phrases]\")) {\n const filterablePhrases = JSON.parse(filterablePhrasesElement.getAttribute(\"data-filterable-phrases\"));\n const filterablePhrasesElementChildren = [];\n for (const filterablePhrase of filterablePhrases) {\n let filterablePhraseElement;\n if (filterPhrases.some(filterPhrase => filterablePhrase.toLowerCase().startsWith(filterPhrase.toLowerCase()))) {\n filterablePhraseElement = document.createElement(\"mark\");\n filterablePhraseElement.classList.add(\"mark\");\n userHidden = false;\n } else\n filterablePhraseElement = document.createElement(\"span\");\n filterablePhraseElement.textContent = filterablePhrase;\n filterablePhrasesElementChildren.push(filterablePhraseElement);\n }\n filterablePhrasesElement.replaceChildren(...filterablePhrasesElementChildren);\n }\n user.hidden = userHidden;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cnujbosyaaqdcf\", function (event) {\n\n this.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"jdbrydgeplprj\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Copy Email\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"copied\",\n tippyProps: {\n theme: \"green\",\n trigger: \"manual\",\n content: \"Copied\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n this.copied.show();\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n this.copied.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"epjpghpduyhztx\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dbafywbukijsii\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update System Role\",\n },\n });\n \n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dnlqsmcstnvnwx\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not update your own role because you\u2019re the only administrator.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hhjiysoglyzxwf\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n appendTo: document.querySelector(\"body\"),\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dyoiglowopypyg\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gkeedxynglvyft\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"btzgovmsiavnys\", function (event) {\n\n this.isModified = false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ejqtnukefrwpfx\", function (event) {\n\n this.onbeforelivenavigate = () => false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cxtolggtbdeecq\", function (event) {\n\n this.onvalidate = () => {\n if (this.value !== this.closest(\"form\").querySelector('[name=\"password\"]').value)\n return \"Password & Password Confirmation don\u2019t match.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"esdxmzcqffotnw\", function (event) {\n\n this.onbeforelivenavigate = () => false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cwuyauxjuvclid\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cehqbdrtxdsiri\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gksecezdqnjilg\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n interactive: true,\n appendTo: document.querySelector(\"body\"),\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"elvrcckyrjckkh\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n interactive: true,\n appendTo: document.querySelector(\"body\"),\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ebjhxcjoygovhp\", function (event, $$0) {\n\n if ($$0)\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Your Vote\", \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gvvnsnhjaqwlb\", function (event, $$0) {\n\n this.style.setProperty(\"--width\", $$0);\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgtznpkxmpyres\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fygkfhtdxkkodz\", function (event) {\n\n this.onclick = () => {\n this.closest(\"form\").isValid = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dnqputwwsbmfbr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"The course staff and the poll creator may see individual votes. Students may see aggregate results.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gkamqhjkkjljer\", function (event) {\n\n this.onclick = async () => {\n const poll = this.closest('[key=\"poll--show\"]');\n for (const element of poll.querySelectorAll('[data-results=\"true\"]:not([data-results-votes=\"true\"])'))\n element.hidden = false;\n poll.querySelector('[key=\"poll--show--actions--show-results\"]').hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gzpzhvrtidwuin\", function (event) {\n\n this.onclick = async () => {\n const poll = this.closest('[key=\"poll--show\"]');\n for (const element of poll.querySelectorAll('[data-results=\"true\"]'))\n element.hidden = true;\n poll.querySelector('[key=\"poll--show--actions--show-results\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bcgyauqzsnkqnz\", function (event, $$0) {\n\n this.onclick = async () => {\n const poll = this.closest('[key=\"poll--show\"]');\n const loading = poll.querySelector('[key=\"poll--show--actions--show-votes--loading\"]');\n loading.hidden = false;\n const partial = leafac.stringToElement(await (await fetch($$0, { cache: \"no-store\" })).text());\n for (const partialElement of partial.querySelectorAll('[key^=\"poll--show--option--votes/\"]')) {\n const element = poll.querySelector('[key=\"' + partialElement.getAttribute(\"key\") + '\"]');\n element.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n leafac.morph(element, partialElement);\n leafac.execute({ element });\n element.hidden = false;\n }\n loading.hidden = true;\n poll.querySelector('[key=\"poll--show--actions--show-votes\"]').hidden = true;\n poll.querySelector('[key=\"poll--show--actions--hide-votes\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xvelukigjqead\", function (event) {\n\n this.onclick = async () => {\n const poll = this.closest('[key=\"poll--show\"]');\n for (const element of poll.querySelectorAll('[key^=\"poll--show--option--votes/\"]'))\n element.hidden = true;\n poll.querySelector('[key=\"poll--show--actions--show-votes\"]').hidden = false;\n poll.querySelector('[key=\"poll--show--actions--hide-votes\"]').hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hbfszpmqhhnbdl\", function (event, $$0) {\n\n this.onclick = async () => {\n const edit = this.closest('[key^=\"poll/\"]').querySelector('[key=\"poll--edit\"]');\n const loading = this.querySelector('[key=\"loading\"]');\n loading.hidden = false;\n edit.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n leafac.morph(edit, await (await fetch($$0, { cache: \"no-store\" })).text());\n loading.hidden = true;\n leafac.execute({ element: edit });\n this.closest('[key^=\"poll/\"]').querySelector('[key=\"poll--show\"]').hidden = true;\n edit.hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gyizffpjgaolrp\", function (event) {\n\n this.onclick = () => {\n this.closest(\"form\").isValid = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fqipjrjpuwmofy\", function (event) {\n\n this.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dyseiaggjnxfyf\", function (event) {\n\n this.isModified = false;\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write\"]').hidden = false;\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--loading\"]').hidden = true;\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--preview\"]').hidden = true; \n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--toolbar--write\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xckzixkklusyc\", function (event, $$0) {\n\n this.isModified = false;\n\n this.onclick = async (event) => {\n const write = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write\"]');\n const loading = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--loading\"]');\n const preview = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--preview\"]');\n const toolbar = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--toolbar--write\"]');\n const textarea = write.querySelector(\"textarea\");\n const previousTextareaRequired = textarea.required;\n textarea.required = true;\n const isWriteValid = leafac.validate(write);\n textarea.required = previousTextareaRequired;\n if (!isWriteValid) {\n event.preventDefault();\n return;\n }\n tippy.hideAll();\n write.hidden = true;\n loading.hidden = false;\n preview.hidden = true;\n toolbar.hidden = true;\n leafac.loadPartial(\n preview,\n await (\n await fetch($$0, {\n method: \"POST\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams({ content: textarea.value, }),\n })\n ).text()\n );\n write.hidden = true;\n loading.hidden = true;\n preview.hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"facmejvuklbwds\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n\n const textarea = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+p\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fohxlxprcbjisq\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"jvxilfbjtrnkh\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fmqrtryuggygem\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Headings\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ehyrhsugzfteej\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"# \", \"HEADING\\n\\n\");\n textarea.selectionEnd += \"HEADING\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"# \", \"\\n\\n\");\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+1\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xjocgfayroegh\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ddkrwleebevugi\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bjjcfxdduflxg\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"## \", \"HEADING\\n\\n\");\n textarea.selectionEnd += \"HEADING\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"## \", \"\\n\\n\");\n textarea.focus(); \n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+2\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gdjxgazekdbpmh\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"### \", \"HEADING\\n\\n\");\n textarea.selectionEnd += \"HEADING\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"### \", \"\\n\\n\");\n textarea.focus(); \n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+3\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bxtbuuqadunpxv\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"---\\n\\n\", \"\");\n textarea.focus(); \n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gqdzcnwabjtvnb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Inline\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dlxrgosvlakxhr\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"**\", \"TEXT**\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"**\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+b\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hkuiirddazqlmj\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"_\", \"TEXT_\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"_\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+i\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gzftlqatvjripx\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"\", \"TEXT\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"\", \"\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+u\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ecylwpybigvfeh\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"~~\", \"TEXT~~\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"~~\");\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+s\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"certivjsclgdtg\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"[\", \"TEXT](https://example.com)\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"[\", \"](https://example.com)\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+k\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hfaxvboicnoidw\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"$\", \"LATEX$\");\n textarea.selectionEnd += \"LATEX\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"$\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+e\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dvncnpenzpowf\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"`\", \"CODE`\");\n textarea.selectionEnd += \"CODE\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"`\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+e\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"qjlmknpsaogqc\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"\", \"TEXT\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"\", \"\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eyxcfuhrescobd\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"~~\", \"TEXT~~\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"~~\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fuikcmtovqceok\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"\", \"TEXT\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"\", \"\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dssbjrxnhowxwx\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"\", \"TEXT\");\n textarea.selectionEnd += \"TEXT\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"\", \"\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bjaeonjhgpfzzn\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--attachments\"]').click();\n };\n\n const textarea = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+k\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"byzjlrqfbuvezb\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgsfrsrdlmeekc\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cclanjnavopzlb\", function (event, $$0, $$1, $$2) {\n\n this.isModified = false;\n\n const textarea = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n\n this.upload = async (fileList) => {\n if (!checkIsSignedIn()) return;\n const body = new FormData();\n for (const file of fileList) body.append(\"attachments\", file);\n this.value = \"\";\n tippy.hideAll();\n textarea.uploadingIndicator.show();\n textarea.disabled = true;\n const response = await (await fetch($$0, {\n method: \"POST\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body,\n })).text();\n textarea.disabled = false;\n textarea.uploadingIndicator.hide();\n textFieldEdit.wrapSelection(textarea, response, \"\");\n textarea.focus();\n };\n\n const checkIsSignedIn = (() => {\n if ($$1) {\n leafac.setTippy({\n event,\n element: textarea,\n tippyProps: {\n trigger: \"manual\",\n theme: \"rose\",\n content: \"You must sign in to upload files.\",\n },\n });\n\n return () => {\n textarea.tooltip.show();\n return false;\n };\n } else\n return () => true;\n })();\n\n leafac.setTippy({\n event,\n element: textarea,\n elementProperty: \"uploadingIndicator\",\n tippyProps: {\n trigger: \"manual\",\n hideOnClick: false,\n content: $$2, \n },\n });\n\n this.onclick = (event) => {\n if (!checkIsSignedIn()) event.preventDefault();\n };\n\n this.onchange = () => {\n this.upload(this.files);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eivbwvgxsowybz\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Block\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hljynlpodxtuj\", function (event, $$0) {\n\n this.onclick = () => {\n tippy.hideAll();\n const write = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write\"]');\n if (write.querySelector('[key=\"poll-editor\"]') !== null) return;\n const poll = leafac.stringToElement($$0).querySelector('[key=\"poll-editor\"]');\n write.insertAdjacentElement(\"afterbegin\", poll);\n leafac.execute({ element: poll });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dmzxespaoycteh\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"- \", \"TEXT\\n\\n\");\n textarea.selectionEnd += \"TEXT\".length;\n } else {\n const replacement = textFieldEdit.getSelection(textarea).split(\"\\n\").map((line) => \"- \" + line).join(\"\\n\");\n const selectionStart = textarea.selectionStart + ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\").length;\n textFieldEdit.insert(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + replacement + \"\\n\\n\");\n textarea.selectionStart = selectionStart;\n textarea.selectionEnd = textarea.selectionStart + replacement.length;\n }\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+8\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ekhgzyigxjdmj\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"1. \", \"TEXT\\n\\n\");\n textarea.selectionEnd += \"TEXT\".length;\n } else {\n const replacement = textFieldEdit.getSelection(textarea).split(\"\\n\").map((line, index) => String(index + 1) + \". \" + line).join(\"\\n\");\n const selectionStart = textarea.selectionStart + ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\").length;\n textFieldEdit.insert(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + replacement + \"\\n\\n\");\n textarea.selectionStart = selectionStart;\n textarea.selectionEnd = textarea.selectionStart + replacement.length;\n }\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+7\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"yhpblaoamkiem\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"- [ ] \", \"TEXT (USE [X] TO MARK ITEM AS DONE)\\n\\n\");\n textarea.selectionEnd += \"TEXT (USE [X] TO MARK ITEM AS DONE)\".length;\n } else {\n const replacement = textFieldEdit.getSelection(textarea).split(\"\\n\").map((line) => \"- [ ] \" + line).join(\"\\n\");\n const selectionStart = textarea.selectionStart + ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\").length;\n textFieldEdit.insert(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + replacement + \"\\n\\n\");\n textarea.selectionStart = selectionStart;\n textarea.selectionEnd = textarea.selectionStart + replacement.length;\n }\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+9\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gfstjluttsgqjn\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"> \", \"TEXT\\n\\n\");\n textarea.selectionEnd += \"TEXT\".length;\n } else {\n const replacement = textFieldEdit.getSelection(textarea).split(\"\\n\").map((line) => \"> \" + line).join(\"\\n\");\n const selectionStart = textarea.selectionStart + ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\").length;\n textFieldEdit.insert(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + replacement + \"\\n\\n\");\n textarea.selectionStart = selectionStart;\n textarea.selectionEnd = textarea.selectionStart + replacement.length;\n }\n textarea.focus();\n };\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+'\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"glqbesfgukvuni\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n const selectionStart = textarea.selectionStart + (textFieldEdit.getSelection(textarea) + ((textarea.selectionEnd > 0) ? \"\\n\\n\" : \"\") + \"| \").length;\n textFieldEdit.insert(textarea, textFieldEdit.getSelection(textarea) + ((textarea.selectionEnd > 0) ? \"\\n\\n\" : \"\") + \"| HEADING | HEADING |\\n|---------|---------|\\n| CONTENT | CONTENT |\\n\\n\");\n textarea.selectionStart = selectionStart;\n textarea.selectionEnd = textarea.selectionStart + \"HEADING\".length;\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+t\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bynzrnmsgneqtt\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"\\n\", \"SUMMARY
\\n\\nCONTENT\\n\\n \\n\\n\");\n textarea.selectionEnd += \"SUMMARY\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"\\nSUMMARY
\\n\\n\", \"\\n\\n \\n\\n\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+d\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gtqhysznbofwwg\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n const identifier = Math.random().toString(36).slice(2);\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, \"[^footnote--\" + identifier + \"]\\n\\n[^footnote--\" + identifier + \"]: \", \"FOOTNOTE\");\n textarea.selectionEnd += \"FOOTNOTE\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, \"[^footnote--\" + identifier + \"]\\n\\n[^footnote--\" + identifier + \"]: \", \"\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+f\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"yunfshwguayeg\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"$$\\n\", \"LATEX\\n$$\\n\\n\");\n textarea.selectionEnd += \"LATEX\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"$$\\n\", \"\\n$$\\n\\n\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+alt+shift+e\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dffmlznzmizqby\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n if (textarea.selectionStart === textarea.selectionEnd) {\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"```\", \"LANGUAGE\\nCODE\\n```\\n\\n\");\n textarea.selectionEnd += \"LANGUAGE\".length;\n }\n else\n textFieldEdit.wrapSelection(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"```LANGUAGE\\n\", \"\\n```\\n\\n\");\n textarea.focus();\n };\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+shift+e\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bvfcojuanyzxdq\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Mentions & References\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cmamorcwetbgqw\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n textFieldEdit.wrapSelection(textarea, \" @\", \"\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bupywzticrrorp\", function (event) {\n\n const textarea = this.closest(\"[data-tippy-root]\")._tippy.reference.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n textFieldEdit.wrapSelection(textarea, \" #\", \"\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eqydkqzyotnzqv\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"psiflgocnvuva\", function (event, $$0) {\n\n this.isModified = false;\n \n const textarea = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n \n this.onchange = async () => {\n textarea.classList[this.checked ? \"add\" : \"remove\"](\"content-editor--write--textarea--programmer-mode\");\n await fetch($$0, {\n method: \"PATCH\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams({ preferContentEditorProgrammerMode: String(this.checked), }),\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"btffumqyrqvhro\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Help\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"csmmcoppnakcqh\", function (event, $$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8) {\n\n if ($$0) this.isModified = false;\n\n autosize(this);\n autosize.update(this);\n \n this.ondragenter = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n this.classList.add(\"drag\");\n };\n this.ondragleave = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n this.classList.remove(\"drag\");\n };\n this.ondragover = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n };\n this.ondrop = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n this.classList.remove(\"drag\");\n const fileList = [...event.dataTransfer.items].flatMap((item) => item.webkitGetAsEntry()?.isFile ?? true ? [item.getAsFile()] : []);\n if (fileList.length > 0)\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--attachments\"]').upload(fileList);\n };\n \n this.onpaste = (event) => {\n window.setTimeout(() => {\n this.closest('[key=\"content-editor\"]').scrollIntoView();\n });\n\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--rich-text-help\"]').hidden = true;\n\n if (leafac.shiftKey) return;\n\n if (event.clipboardData.types.includes(\"text/html\")) {\n if (!leafac.isPhysicalKeyboard) return;\n\n event.preventDefault();\n\n const placeholder = \"\u25CA\u25CA\" + Math.random().toString(36).slice(2) + \"\u25CA\u25CA\";\n const replacements = [];\n\n const html = leafac.stringToElement(event.clipboardData.getData(\"text/html\"));\n\n for (const element of html.querySelectorAll(\".katex, .katex-display\")) {\n const annotation = element.querySelector('annotation[encoding=\"application/x-tex\"]');\n if (annotation === null) continue;\n replacements.push(\n (element.matches(\".katex-display\") ? \"\\n\\n$$\\n\" : \"$\") +\n annotation.textContent +\n (element.matches(\".katex-display\") ? \"\\n$$\\n\\n\" : \"$\")\n );\n element.outerHTML = \"\" + placeholder + \"\";\n }\n\n textFieldEdit.insert(\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]'),\n unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeRemark)\n .use(remarkGfm, { singleTilde: false })\n .use(remarkStringify)\n .processSync(html.innerHTML)\n .toString()\n .replaceAll(placeholder, () => replacements.shift())\n );\n\n const richTextHelp = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--rich-text-help\"]');\n richTextHelp.hidden = false;\n window.clearTimeout(richTextHelp.hideTimeout);\n richTextHelp.hideTimeout = window.setTimeout(() => {\n richTextHelp.hidden = true;\n }, 10 * 1000);\n } else if (event.clipboardData.types.includes(\"Files\")) {\n event.preventDefault();\n const fileList = [...event.clipboardData.items].flatMap((item) => item.webkitGetAsEntry()?.isFile ?? true ? [item.getAsFile()] : []);\n if (fileList.length > 0)\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--attachments\"]').upload(fileList);\n }\n };\n \n if ($$1) {\n const dropdownMenuTarget = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea--dropdown-menu-target\"]');\n \n const dropdownMenus = [\n {\n trigger: \"@\",\n route: $$2,\n dropdownMenu: leafac.setTippy({\n event,\n element: dropdownMenuTarget,\n elementProperty: \"dropdownMenuMention\",\n tippyProps: {\n placement: \"bottom-start\",\n trigger: \"manual\",\n interactive: true,\n onHidden: (dropdown) => {\n leafac.loadPartial(\n dropdown.props.content.querySelector('[key=\"search-results\"]'),\n $$3\n );\n },\n content: $$4, \n },\n }),\n },\n {\n trigger: \"#\",\n route: $$5,\n dropdownMenu: leafac.setTippy({\n event,\n element: dropdownMenuTarget,\n elementProperty: \"dropdownMenuReference\",\n tippyProps: {\n placement: \"bottom-start\",\n trigger: \"manual\",\n interactive: true,\n onHidden: (dropdown) => {\n leafac.loadPartial(\n dropdown.props.content.querySelector('[key=\"search-results\"]'),\n $$6\n );\n },\n content: $$7, \n },\n }),\n },\n ];\n \n this.isUpdating ??= false;\n this.shouldUpdateAgain ??= false;\n this.oninput = async () => {\n for (const { trigger, route, dropdownMenu } of dropdownMenus) {\n if (!dropdownMenu.state.isShown) {\n if (\n (this.selectionStart > 1 && this.value[this.selectionStart - 2].match(/^\\s$/) === null) ||\n this.value[this.selectionStart - 1] !== trigger\n ) continue;\n this.anchorIndex = this.selectionStart;\n const caretCoordinates = textareaCaret(this, this.selectionStart);\n dropdownMenuTarget.style.top = String(caretCoordinates.top - this.scrollTop) + \"px\";\n dropdownMenuTarget.style.left = String(caretCoordinates.left - 14) + \"px\";\n tippy.hideAll();\n dropdownMenu.show();\n }\n const search = this.value.slice(this.anchorIndex, this.selectionStart);\n if (this.selectionStart < this.anchorIndex || search.match(/[^a-z0-9\\/]/i) !== null) {\n dropdownMenu.hide();\n continue;\n }\n if (this.isUpdating) {\n this.shouldUpdateAgain = true;\n continue;\n }\n this.isUpdating = true;\n this.shouldUpdateAgain = false;\n const content = dropdownMenu.props.content;\n leafac.loadPartial(\n content.querySelector('[key=\"search-results\"]'),\n await (await fetch(route + \"?\" + new URLSearchParams({ search }), { cache: \"no-store\" })).text()\n );\n const buttons = content.querySelectorAll(\".button\");\n for (const button of buttons) button.classList.remove(\"hover\");\n if (buttons.length > 0) buttons[0].classList.add(\"hover\");\n this.isUpdating = false;\n if (this.shouldUpdateAgain) this.oninput();\n }\n };\n \n this.onkeydown = (event) => {\n for (const { dropdownMenu } of dropdownMenus) {\n if (!dropdownMenu.state.isShown) continue;\n const content = dropdownMenu.props.content;\n switch (event.code) {\n case \"ArrowUp\":\n case \"ArrowDown\":\n event.preventDefault();\n const buttons = [...content.querySelectorAll(\".button\")];\n if (buttons.length === 0) continue; \n const currentHoverIndex = buttons.indexOf(content.querySelector(\".button.hover\"));\n if (\n currentHoverIndex === -1 ||\n (event.code === \"ArrowUp\" && currentHoverIndex === 0) ||\n (event.code === \"ArrowDown\" && currentHoverIndex === buttons.length - 1)\n ) continue;\n buttons[currentHoverIndex].classList.remove(\"hover\");\n const buttonToHover = buttons[currentHoverIndex + (event.code === \"ArrowUp\" ? -1 : 1)];\n buttonToHover.classList.add(\"hover\");\n scrollIntoViewIfNeeded(buttonToHover, { scrollMode: \"if-needed\" });\n break;\n case \"Enter\":\n case \"Tab\":\n event.preventDefault();\n const buttonHover = content.querySelector(\".button.hover\");\n if (buttonHover === null) dropdownMenu.hide();\n else {\n event.preventDefault();\n buttonHover.click();\n }\n break;\n case \"Escape\":\n case \"ArrowLeft\":\n case \"ArrowRight\":\n case \"Home\":\n case \"End\":\n dropdownMenu.hide();\n break;\n }\n }\n };\n \n this.dropdownMenuComplete = (text) => {\n tippy.hideAll();\n this.setSelectionRange(this.anchorIndex, this.selectionStart);\n textFieldEdit.insert(this, text);\n this.focus();\n };\n\n this.onclick = this.onkeyup = () => {\n if (this.closest('[key=\"content-editor\"]').querySelector('[key=\"poll-editor\"]') !== null) return;\n \n for (const match of this.value.matchAll(/\\d+)\"><\\/courselore-poll>/g))\n if (match.index <= this.selectionStart && this.selectionStart <= match.index + match[0].length) {\n const caretCoordinates = textareaCaret(this, this.selectionStart);\n dropdownMenuTarget.style.top = String(caretCoordinates.top - this.scrollTop) + \"px\";\n dropdownMenuTarget.style.left = String(caretCoordinates.left) + \"px\";\n\n (window.locals ??= {}).editPollReference = match.groups.pollReference;\n\n leafac.setTippy({\n element: dropdownMenuTarget,\n elementProperty: \"dropdownPollEdit\",\n tippyProps: {\n trigger: \"manual\",\n interactive: true,\n content: $$8, \n },\n });\n\n tippy.hideAll();\n dropdownMenuTarget.dropdownPollEdit.show();\n\n return;\n }\n\n dropdownMenuTarget.dropdownPollEdit?.hide?.();\n };\n }\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xjigshzovofoo\", function (event, $$0, $$1) {\n\n this.onclick = async () => {\n const loading = this.querySelector('[key=\"loading\"]');\n loading.hidden = false;\n const response = await fetch($$0 + window.locals.editPollReference + $$1, { cache: \"no-store\" });\n loading.hidden = true;\n if (!response.ok) {\n leafac.setTippy({\n element: this,\n elementProperty: \"errorTooltip\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"manual\",\n content: await response.text(),\n },\n });\n this.errorTooltip.show();\n return;\n }\n const poll = leafac.stringToElement(await response.text()).querySelector('[key=\"poll-editor\"]');\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write\"]').insertAdjacentElement(\"afterbegin\", poll);\n leafac.execute({ element: poll });\n tippy.hideAll();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"mjctjpydscnjb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Toolbar\",\n },\n });\n\n this.onclick = async () => {\n const toolbar = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--toolbar\"]');\n toolbar.hidden = !toolbar.hidden;\n await fetch($$0, {\n method: \"PATCH\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams({ preferContentEditorToolbarInCompact: String(!toolbar.hidden), }),\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dhyefjsdptkwkh\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"egzotlclqisjog\", function (event) {\n\n this.hidden = !leafac.isAppleDevice || leafac.isSafari;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eayrnwwbutfkok\", function (event) {\n\n this.hidden = !leafac.isAppleDevice || !leafac.isSafari;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gtgpfsftryymxy\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Drag to Reorder\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"chhwjcsqwdodii\", function (event) {\n\n this.isModified = true;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cgfcsrrfdoeyou\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Remove Option\",\n },\n });\n\n this.onclick = () => {\n const options = this.closest('[key=\"poll-editor--options\"]');\n this.closest('[key^=\"poll-editor--option/\"]').remove();\n options.reorder();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fmtbsuybrhczbt\", function (event) {\n\n this.onchange = () => {\n const closesAt = this.closest('[key=\"poll-editor\"]').querySelector('[key=\"poll-editor--closes-at\"]');\n closesAt.hidden = !this.checked;\n for (const element of leafac.descendants(closesAt))\n if (element.disabled !== undefined) element.disabled = !this.checked;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"csrfiwxfndjaaq\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Closing\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gbmirgzmzjxjxg\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Not Closing\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gtyropbwqlabsa\", function (event, $$0) {\n\n this.value = this.defaultValue = leafac.localizeDateTime(this.defaultValue);\n\n this.onvalidate = () => {\n const mustBeInTheFuture = $$0 || leafac.isModified(this);\n const error = leafac.validateLocalizedDateTime(this);\n if (typeof error === \"string\") return error;\n if (mustBeInTheFuture && new Date(this.value).getTime() <= Date.now()) return \"Must be in the future.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bbbggmjwqmzrnd\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"This datetime will be converted to UTC, which may lead to surprising off-by-one-hour differences if it crosses a daylight saving time change.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bqyhskdopbxzqb\", function (event) {\n\n this.onbeforemorph = (event) => {\n const liveUpdate = event?.detail?.liveUpdate;\n if (!liveUpdate) this.isModified = false;\n return !liveUpdate;\n };\n\n this.onpointerdown = (event) => {\n if (event.target.closest('[key=\"poll-editor--option--grab--handle\"]') === null) return;\n\n const body = document.querySelector(\"body\");\n const option = event.target.closest('[key^=\"poll-editor--option/\"]');\n\n this.grabbed = option;\n body.classList.add(\"grabbing\");\n option.classList.add(\"grabbed\");\n\n body.addEventListener(\"pointerup\", () => {\n delete this.grabbed;\n body.classList.remove(\"grabbing\");\n option.classList.remove(\"grabbed\");\n }, { once: true });\n };\n\n this.onpointermove = (event) => {\n const option = (\n event.pointerType === \"touch\" ? document.elementFromPoint(event.clientX, event.clientY) : event.target\n ).closest('[key^=\"poll-editor--option/\"]');\n if (option === null || [undefined, option].includes(this.grabbed)) return;\n\n const boundingClientRect = option.getBoundingClientRect();\n option[\n (event.clientY - boundingClientRect.top) / (boundingClientRect.bottom - boundingClientRect.top) < 0.5 ?\n \"after\" : \"before\"\n ](this.grabbed);\n this.reorder();\n };\n\n this.onkeydown = (event) => {\n if (event.target.closest('[key=\"poll-editor--option--grab--handle\"]') === null) return;\n\n const option = event.target.closest('[key^=\"poll-editor--option/\"]');\n switch (event.code) {\n case \"ArrowUp\":\n event.preventDefault();\n option.previousElementSibling?.before?.(option);\n break;\n case \"ArrowDown\":\n event.preventDefault();\n option.nextElementSibling?.after?.(option);\n break;\n }\n option.querySelector('[key=\"poll-editor--option--grab--handle\"]').focus();\n this.reorder();\n };\n\n this.reorder = () => {\n this.isModified = true;\n\n for (const [order, option] of this.querySelectorAll('[key^=\"poll-editor--option/\"]').entries())\n for (const element of option.querySelectorAll('[name^=\"options[\"]'))\n element.setAttribute(\"name\", element.getAttribute(\"name\").replace(/\\d+/, String(order)));\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"exwpsspzzwyyrt\", function (event, $$0, $$1) {\n\n this.onclick = () => {\n const newOption = leafac.stringToElement($$0).querySelector('[key=\"poll-editor--option/new\"]');\n\n const options = this.closest('[key=\"poll-editor\"]').querySelector('[key=\"poll-editor--options\"]');\n options.insertAdjacentElement(\"beforeend\", newOption);\n leafac.execute({ element: newOption });\n options.reorder();\n };\n\n if ($$1 && !event?.detail?.liveUpdate)\n for (const initialOptions of new Array(3))\n this.onclick();\n\n this.onvalidate = () => {\n if (this.closest(\"[hidden]\") === null && this.closest('[key=\"poll-editor\"]').querySelector('[key=\"poll-editor--options\"]').children.length <= 1)\n return \"Please add at least two options.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gbdntyzeftbwir\", function (event, $$0, $$1, $$2, $$3) {\n\n if (this.closest('[key^=\"poll/\"]') !== null) return;\n \n this.setAttribute(\"type\", \"button\");\n\n this.onclick = async () => {\n const pollEditor = this.closest('[key=\"poll-editor\"]');\n const textarea = this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]');\n\n if (!leafac.validate(pollEditor)) return;\n\n const body = leafac.serialize(pollEditor);\n\n leafac.morph(pollEditor.querySelector('[key=\"poll-editor--content\"]'), $$0);\n\n const content = await (await fetch($$1, {\n method: $$2,\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body,\n })).text();\n\n pollEditor.remove();\n\n if ($$3)\n textFieldEdit.insert(textarea, ((textarea.selectionStart > 0) ? \"\\n\\n\" : \"\") + content + \"\\n\\n\");\n textarea.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"heimpcszlmschn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"The course staff and the poll creator may see individual votes. Students may see aggregate results.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cmehjvrjwpzuhx\", function (event) {\n\n this.onclick = () => {\n this.closest(\"form\").isValid = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bnmtlcadhhdzys\", function (event) {\n\n this.onclick = () => {\n const poll = this.closest('[key^=\"poll/\"]');\n if (poll !== null) {\n poll.querySelector('[key=\"poll--show\"]').hidden = false;\n poll.querySelector('[key=\"poll--edit\"]').hidden = true;\n }\n this.closest('[key=\"poll-editor\"]').remove();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dcwlqygbczyvjo\", function (event, $$0) {\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]').dropdownMenuComplete($$0);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"feceudlgdbmhfy\", function (event, $$0) {\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]').dropdownMenuComplete($$0);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"drptlmiszhqasm\", function (event, $$0) {\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]').dropdownMenuComplete($$0);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hwnqazbnrwqmf\", function (event, $$0) {\n\n this.onclick = () => {\n this.closest('[key=\"content-editor\"]').querySelector('[key=\"content-editor--write--textarea\"]').dropdownMenuComplete($$0);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gfuqkssrfzptiq\", function (event) {\n\n this.isModified = false;\n\n this.onchange = () => {\n const searchAndFilters = this.closest('[key=\"search-and-filters\"]');\n const searchAndFiltersForm = searchAndFilters.querySelector('[key=\"search-and-filters--form\"]');\n const searchAndFiltersFormSection = searchAndFiltersForm.querySelector('[key=\"search\"]');\n searchAndFiltersForm.hidden = [...searchAndFilters.querySelectorAll('[key=\"search-and-filters--show-hide--search\"], [key=\"search-and-filters--show-hide--filters\"]')]\n .every((element) => !element.checked);\n searchAndFiltersFormSection.hidden = !this.checked;\n for (const element of leafac.descendants(searchAndFiltersFormSection))\n if (element.disabled !== undefined) element.disabled = !this.checked;\n if (this.checked)\n searchAndFiltersFormSection.querySelector('[name=\"conversations[search]\"]').focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gjstnnbucuabov\", function (event) {\n\n this.isModified = false;\n \n this.onchange = () => {\n const searchAndFilters = this.closest('[key=\"search-and-filters\"]');\n const searchAndFiltersForm = searchAndFilters.querySelector('[key=\"search-and-filters--form\"]');\n const searchAndFiltersFormSection = searchAndFiltersForm.querySelector('[key=\"filters\"]');\n searchAndFiltersForm.hidden = [...searchAndFilters.querySelectorAll('[key=\"search-and-filters--show-hide--search\"], [key=\"search-and-filters--show-hide--filters\"]')]\n .every((element) => !element.checked);\n searchAndFiltersFormSection.hidden = !this.checked;\n for (const element of leafac.descendants(searchAndFiltersFormSection))\n if (element.disabled !== undefined) element.disabled = !this.checked;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"femqpwqrbwiqsx\", function (event) {\n\n this.isModified = false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dbjapxrflgnmgw\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Search\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ekehlzhvuftapk\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Clear Search\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bjwfokvcuwhfdb\", function (event) {\n\n this.onchange = () => {\n if (this.checked) this.closest(\"form\").querySelector('[name=\"conversations[filters][isUnread]\"][value=\"false\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ebgvhynffhsxak\", function (event) {\n\n this.onchange = () => {\n if (this.checked) this.closest(\"form\").querySelector('[name=\"conversations[filters][isUnread]\"][value=\"true\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dypnwkufmxvvgr\", function (event, $$0, $$1) {\n\n if ($$0)\n this.onchange = () => {\n if (this.checked) return;\n for (const element of this.closest(\"form\").querySelectorAll($$1))\n element.checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dbkxmrgdeplayl\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) return;\n const form = this.closest(\"form\");\n form.querySelector('[name=\"conversations[filters][types][]\"][value=\"question\"]').checked = true;\n form.querySelector('[name=\"conversations[filters][isResolved]\"][value=\"true\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gcogcfyviouqyy\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) return;\n const form = this.closest(\"form\");\n form.querySelector('[name=\"conversations[filters][types][]\"][value=\"question\"]').checked = true;\n form.querySelector('[name=\"conversations[filters][isResolved]\"][value=\"false\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ezwwyzqtfydlpl\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) return;\n const form = this.closest(\"form\");\n form.querySelector('[name=\"conversations[filters][types][]\"][value=\"note\"]').checked = true;\n form.querySelector('[name=\"conversations[filters][isAnnouncement]\"][value=\"true\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dfpctuqfdpxduh\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) return;\n const form = this.closest(\"form\");\n form.querySelector('[name=\"conversations[filters][types][]\"][value=\"note\"]').checked = true;\n form.querySelector('[name=\"conversations[filters][isAnnouncement]\"][value=\"false\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"csyvcbcobgwtwk\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Pinned conversations are listed first.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cjojxhydfjogox\", function (event) {\n\n this.onchange = () => {\n if (this.checked) this.closest(\"form\").querySelector('[name=\"conversations[filters][isPinned]\"][value=\"false\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"efydbcpyknmdkh\", function (event) {\n\n this.onchange = () => {\n if (this.checked) this.closest(\"form\").querySelector('[name=\"conversations[filters][isPinned]\"][value=\"true\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fohuijiatglji\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Tags help to organize conversations.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fatfqywkvpxcwr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"izesevbcxewwe\", function (event, $$0, $$1, $$2) {\n\n if ($$0)\n window.setTimeout(() => {\n if (event?.detail?.previousLocation?.href?.startsWith($$1)) return;\n this.querySelector($$2)?.scrollIntoView({ block: \"center\" });\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"zdigolwjbjocd\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Mark as Read\",\n },\n });\n \n this.onclick = async (event) => {\n event.preventDefault();\n event.stopImmediatePropagation();\n await fetch(this.closest(\"a\").getAttribute(\"href\"), { cache: \"no-store\" });\n this.remove();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"lbnenfqudyhoy\", function (event, $$0, $$1, $$2) {\n\n if ($$0) {\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n interactive: true,\n delay: [1000, null],\n touch: [\"hold\", 1000],\n onHidden: () => { this.onmouseleave(); },\n content: $$1, \n },\n });\n\n window.clearTimeout(this.tooltipContentTimeout);\n this.tooltipContentSkipLoading = false;\n \n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.tooltipContentSkipLoading) return;\n this.tooltipContentSkipLoading = true;\n leafac.loadPartial(this.tooltip.props.content.querySelector('[key=\"content\"]'), await (await fetch($$2, { cache: \"no-store\" })).text());\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.tooltip.setProps({});\n };\n \n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.tooltip.state.isShown) return;\n this.tooltipContentTimeout = window.setTimeout(() => {\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.tooltipContentSkipLoading = false;\n }, 60 * 1000);\n };\n }\n else\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Participants\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"wlhbriuldkesm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Pinned conversations are listed first.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fsvdsfoqcnbztz\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Conversation Reference\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dihgzsisrdwxhm\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { capitalize: true });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fgurcyafrdmtbv\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cudhaawkpvdeua\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ghdutqthnbvmyw\", function (event, $$0, $$1, $$2, $$3) {\n\n this.onchange = () => {\n const form = this.closest(\"form\");\n for (const element of [form.querySelector('[name=\"content\"]'), ...form.querySelectorAll('[name=\"tagsReferences[]\"]')])\n element.required = $$0;\n\n if ($$1) {\n const notification = form.querySelector('[key=\"new-conversation--announcement\"]');\n notification.hidden = $$2;\n for (const element of leafac.descendants(notification))\n if (element.disabled !== undefined)\n element.disabled = $$3;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"celninyzezxjjf\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Tags help to organize conversations.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ffpqrtvqjdwlpn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgtcivswnjfzsb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gqkbwxncththzy\", function (event, $$0, $$1, $$2, $$3) {\n\n this.isModified = false;\n\n this.onchange = () => { \n this.closest(\"form\").querySelector($$0).checked = true;\n\n const participantsDropdown = this.closest('[key=\"participants--dropdown\"]');\n const selectedParticipants = participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants\"]');\n\n if ($$1) {\n selectedParticipants.hidden = true;\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = true;\n } else if ($$2) {\n selectedParticipants.hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--course-staff\"]').hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--selected-participants\"]').hidden = true;\n\n for (const element of selectedParticipants.querySelectorAll('[data-course-participant-course-role=\"course-staff\"]'))\n element.hidden = true;\n participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants--filter\"]')?.oninput();\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = element.matches('[data-course-participant-course-role=\"course-staff\"]');\n\n (this.closest(\"form\").querySelector('[name=\"isAnnouncement\"]') ?? {}).checked = false;\n (this.closest(\"form\").querySelector('[name=\"isPinned\"]') ?? {}).checked = false;\n } else if ($$3) {\n selectedParticipants.hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--course-staff\"]').hidden = true;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--selected-participants\"]').hidden = false;\n\n for (const element of selectedParticipants.querySelectorAll('[data-course-participant-course-role=\"course-staff\"]'))\n element.hidden = false;\n participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants--filter\"]')?.oninput();\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = false;\n\n (this.closest(\"form\").querySelector('[name=\"isAnnouncement\"]') ?? {}).checked = false;\n (this.closest(\"form\").querySelector('[name=\"isPinned\"]') ?? {}).checked = false;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cnpgqwsdniowcr\", function (event) {\n\n this.isModified = false;\n\n this.oninput = () => {\n const filterPhrases = this.value.split(/[^a-z0-9]+/i).filter((filterPhrase) => filterPhrase.trim() !== \"\");\n const participantsDropdown = this.closest('[key=\"participants--dropdown\"]');\n const participantsIsCourseStaff = participantsDropdown.querySelector('[name=\"participants--dropdown--participants\"][value=\"course-staff\"]').checked;\n for (const selectedParticipant of participantsDropdown.querySelectorAll('[key^=\"participants--dropdown--selected-participant--course-participant-reference--\"]')) {\n if (participantsIsCourseStaff && selectedParticipant.matches('[data-course-participant-course-role=\"course-staff\"]'))\n continue;\n let selectedParticipantHidden = filterPhrases.length > 0;\n for (const filterablePhrasesElement of selectedParticipant.querySelectorAll(\"[data-filterable-phrases]\")) {\n const filterablePhrases = JSON.parse(filterablePhrasesElement.getAttribute(\"data-filterable-phrases\"));\n const filterablePhrasesElementChildren = [];\n for (const filterablePhrase of filterablePhrases) {\n let filterablePhraseElement;\n if (filterPhrases.some(filterPhrase => filterablePhrase.toLowerCase().startsWith(filterPhrase.toLowerCase()))) {\n filterablePhraseElement = document.createElement(\"mark\");\n filterablePhraseElement.classList.add(\"mark\");\n selectedParticipantHidden = false;\n } else\n filterablePhraseElement = document.createElement(\"span\");\n filterablePhraseElement.textContent = filterablePhrase;\n filterablePhrasesElementChildren.push(filterablePhraseElement);\n }\n filterablePhrasesElement.replaceChildren(...filterablePhrasesElementChildren);\n }\n selectedParticipant.hidden = selectedParticipantHidden;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bdjlkikxwhsgig\", function (event, $$0) {\n\n this.isModified = false;\n\n this.onchange = () => {\n this.closest(\"form\").querySelector($$0).checked = this.checked;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"csfpsjmvtwltcf\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Remove Participant\",\n },\n });\n\n this.onclick = () => {\n this.previousElementSibling.checked = false;\n\n this.closest(\"form\").querySelector('[key=\"participants\"]').dropdown.props.content.querySelector($$0).checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dmmcpcdtxzvbte\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Course participants receive immediate email notifications for announcements.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gdkhdguciyouns\", function (event) {\n\n this.onchange = () => {\n if (this.checked) this.closest(\"form\").querySelector('[name=\"isPinned\"]').checked = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dqphxvuvlbggdy\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Announcement\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bezwquphlfwvrv\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Not an Announcement\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgdpnkafffobub\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Pinned conversations are listed first.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bmlplysguoriou\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Pin\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dyxtupdzjovczr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Unpin\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gkkkxmkzokbyjl\", function (event, $$0) {\n\n this.isModified = false;\n\n this.onchange = async () => {\n await fetch($$0, {\n method: \"PATCH\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams({ preferAnonymous: String(this.checked), }),\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"mbgrdrjnvyhzc\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Anonymous to Other Students\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"clkkjkhzvesskc\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Signed by You\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"blrqalktahfbyd\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n\n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+enter\", () => { this.click(); return false; });\n\n this.onclick = () => {\n delete this.closest(\"form\").isValid;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fdcnrdpmnyodmz\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gculjmwuflqfas\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bhrajnhdpqlhsu\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n\n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n\n // TODO: Conversation drafts\n // (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+s\", () => { this.click(); return false; });\n\n this.onclick = () => {\n this.closest(\"form\").isValid = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gufidtfktralky\", function (event) {\n\n this.onclick = () => {\n this.closest('[key=\"conversation--header\"]').querySelector('[key=\"conversation--header--compact\"]').hidden = true;\n this.closest('[key=\"conversation--header\"]').querySelector('[key=\"conversation--header--full\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eotmgskzswxwtw\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Conversation Type\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fsueeflaesehm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Resolved\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dcyihoxarsrsxx\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Unresolved\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"elixpulsaiabsa\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Announcement\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cctaacfkeemisn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Not an Announcement\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ohhhcicevxfkc\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Pin\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"crilkotalvybij\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Unpin\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fjvumdjhidjvml\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Actions\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ehuowpbyxxtyaj\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"copied\",\n tippyProps: {\n theme: \"green\",\n trigger: \"manual\",\n content: \"Copied\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n this.copied.show();\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n this.copied.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cdmvdwirjbopbg\", function (event) {\n\n this.onclick = () => {\n this.closest('[key=\"conversation--header--full\"]').querySelector('[key=\"title--show\"]').hidden = true;\n this.closest('[key=\"conversation--header--full\"]').querySelector('[key=\"title--edit\"]').hidden = false;\n tippy.hideAll();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gdwouipkujztyn\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.tooltipContentTimeout);\n this.tooltipContentSkipLoading = false;\n \n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.tooltipContentSkipLoading) return;\n this.tooltipContentSkipLoading = true;\n leafac.loadPartial(this.tooltip.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.tooltip.setProps({});\n };\n \n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.tooltip.state.isShown) return;\n this.tooltipContentTimeout = window.setTimeout(() => {\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.tooltipContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"tzxegqycqnvz\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"elcfkhevverjyl\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"green\",\n touch: false,\n content: \"Update Title\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gqaayuhapxtgey\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Cancel\",\n },\n });\n\n this.onclick = () => {\n this.closest('[key=\"conversation--header--full\"]').querySelector('[key=\"title--show\"]').hidden = false;\n this.closest('[key=\"conversation--header--full\"]').querySelector('[key=\"title--edit\"]').hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hdkzcdmkfozgkd\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"You may not remove this tag because a conversation must have at least one tag.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"exfyvjuvrzoex\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bpuunaikgxofra\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Remove Tag\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dygpwbkrjzdogd\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Add Tag\",\n },\n });\n \n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dffcwuzmvlueoi\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hbkzpzuvryurot\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"You may not remove this tag because a conversation must have at least one tag.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fuctdlnvdrkchb\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"This tag is visible by the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"echtropfiiccjm\", function (event) {\n\n this.onbeforemorphattribute = (event, attribute) => [\"hidden\", \"disabled\", \"checked\"].includes(attribute);\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hiylvwniommwqx\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n placement: \"bottom\",\n onHide: () => {\n const form = this.closest(\"form\");\n if (leafac.isModified(form)) form.querySelector('[key=\"submit\"] button').click();\n },\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fjivxrpopnyvdw\", function (event, $$0, $$1, $$2, $$3) {\n\n this.isModified = false;\n\n this.onchange = () => {\n this.closest(\"form\").querySelector($$0).checked = true;\n\n const participantsDropdown = this.closest('[key=\"participants--dropdown\"]');\n const selectedParticipants = participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants\"]');\n\n if ($$1) {\n selectedParticipants.hidden = true;\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = true;\n } else if ($$2) {\n selectedParticipants.hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--course-staff\"]').hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--selected-participants\"]').hidden = true;\n\n for (const element of selectedParticipants.querySelectorAll('[data-course-participant-course-role=\"course-staff\"]'))\n element.hidden = true;\n participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants--filter\"]')?.oninput();\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = element.matches('[data-course-participant-course-role=\"course-staff\"]');\n } else if ($$3) {\n selectedParticipants.hidden = false;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--course-staff\"]').hidden = true;\n selectedParticipants.querySelector('[key=\"participants--dropdown--selected-participants--separator--selected-participants\"]').hidden = false;\n\n for (const element of selectedParticipants.querySelectorAll('[data-course-participant-course-role=\"course-staff\"]'))\n element.hidden = false;\n participantsDropdown.querySelector('[key=\"participants--dropdown--selected-participants--filter\"]')?.oninput();\n\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"selectedParticipantsReferences[]\"]'))\n element.disabled = false;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"clrjdoxhcuifne\", function (event) {\n\n this.isModified = false;\n\n this.oninput = () => {\n const filterPhrases = this.value.split(/[^a-z0-9]+/i).filter((filterPhrase) => filterPhrase.trim() !== \"\");\n const participantsDropdown = this.closest('[key=\"participants--dropdown\"]');\n const participantsIsCourseStaff = participantsDropdown.querySelector('[name=\"participants--dropdown--participants\"][value=\"course-staff\"]').checked;\n for (const selectedParticipant of participantsDropdown.querySelectorAll('[key^=\"participants--dropdown--selected-participant--course-participant-reference--\"]')) {\n if (participantsIsCourseStaff && selectedParticipant.matches('[data-course-participant-course-role=\"course-staff\"]'))\n continue;\n let selectedParticipantHidden = filterPhrases.length > 0;\n for (const filterablePhrasesElement of selectedParticipant.querySelectorAll(\"[data-filterable-phrases]\")) {\n const filterablePhrases = JSON.parse(filterablePhrasesElement.getAttribute(\"data-filterable-phrases\"));\n const filterablePhrasesElementChildren = [];\n for (const filterablePhrase of filterablePhrases) {\n let filterablePhraseElement;\n if (filterPhrases.some(filterPhrase => filterablePhrase.toLowerCase().startsWith(filterPhrase.toLowerCase()))) {\n filterablePhraseElement = document.createElement(\"mark\");\n filterablePhraseElement.classList.add(\"mark\");\n selectedParticipantHidden = false;\n } else\n filterablePhraseElement = document.createElement(\"span\");\n filterablePhraseElement.textContent = filterablePhrase;\n filterablePhrasesElementChildren.push(filterablePhraseElement);\n }\n filterablePhrasesElement.replaceChildren(...filterablePhrasesElementChildren);\n }\n selectedParticipant.hidden = selectedParticipantHidden;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dkjzwzdslnohsu\", function (event, $$0) {\n\n this.isModified = false;\n\n this.onchange = () => {\n this.closest(\"form\").querySelector($$0).checked = this.checked;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"darqtrhgrudpsz\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Remove Participant\",\n },\n });\n\n this.onclick = () => {\n this.previousElementSibling.checked = false;\n\n this.closest(\"form\").querySelector('[key=\"participants\"]').dropdown.props.content.querySelector($$0).checked = false;\n\n this.closest(\"form\").querySelector('[key=\"submit\"]').hidden = !leafac.isModified(this.closest(\"form\"));\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gnbbkdjkudhywz\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Participants\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fsldwxklnudxap\", function (event) {\n\n this.onclick = () => {\n this.closest('[key=\"conversation--header\"]').querySelector('[key=\"conversation--header--full\"]').hidden = true;\n this.closest('[key=\"conversation--header\"]').querySelector('[key=\"conversation--header--compact\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xskpniwpsnmkp\", function (event, $$0, $$1, $$2, $$3, $$4, $$5, $$6) {\n\n const scroll = () => {\n if (\n [undefined, \"GET\", \"HEAD\", \"OPTIONS\", \"TRACE\"].includes(event?.detail?.request?.method) &&\n !event?.detail?.liveUpdate\n ) {\n if ($$0) {\n const element = this.querySelector($$1);\n if (element === null) return;\n element.scrollIntoView();\n const messageHighlight = element.querySelector('[key=\"message--highlight\"]');\n messageHighlight.style.animation = \"message--highlight 2s var(--transition-timing-function--in-out)\";\n messageHighlight.onanimationend = () => {\n messageHighlight.style.animation = \"\";\n };\n } else if ($$2) {\n this.querySelector($$3)?.scrollIntoView();\n } else if ($$4) {\n this.scroll(0, this.scrollHeight);\n }\n }\n else if ($$5 && this.shouldScrollConversationToBottom) {\n this.scroll(0, this.scrollHeight);\n }\n\n if ($$6) {\n this.onscroll = () => {\n this.shouldScrollConversationToBottom = this.scrollTop === this.scrollHeight - this.offsetHeight;\n };\n this.onscroll();\n }\n };\n window.addEventListener(\"livenavigateself\", scroll);\n window.addEventListener(\"livenavigate\", () => {\n window.removeEventListener(\"livenavigateself\", scroll);\n }, { once: true });\n window.setTimeout(scroll);\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"czcbwistobdtos\", function (event) {\n\n if (this !== document.querySelector('[key=\"message--new-separator\"]')) {\n this.remove();\n return;\n }\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Close\",\n },\n });\n \n this.onclick = () => {\n this.remove();\n };\n\n this.onbeforeremove = () => false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"frmteacjzaqvni\", function (event) {\n\n const element = this;\n leafac.relativizeDateElement(element);\n\n window.clearTimeout(element.updateTimeout);\n (function update() {\n if (!leafac.isConnected(element)) return;\n const dateSeparators = [...document.querySelectorAll('[key=\"message--date-separator\"]')];\n const thisDateSeparator = element.closest('[key=\"message--date-separator\"]');\n const thisDateSeparatorIndex = dateSeparators.indexOf(thisDateSeparator);\n const previousDateSeparator = thisDateSeparatorIndex <= 0 ? undefined : dateSeparators[thisDateSeparatorIndex - 1];\n thisDateSeparator.hidden = previousDateSeparator !== undefined && previousDateSeparator.textContent === thisDateSeparator.textContent;\n element.updateTimeout = window.setTimeout(update, 60 * 1000 + Math.random() * 10 * 1000);\n })();\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eszvxpzwupllrg\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Course staff whispers are messages visible to the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bzwgtvkaxztoma\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Actions\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.dropdownContentTimeout);\n this.dropdownContentSkipLoading = false;\n\n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.dropdownContentTimeout);\n if (this.dropdownContentSkipLoading) return;\n this.dropdownContentSkipLoading = true;\n leafac.loadPartial(this.dropdown.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.dropdown.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.dropdown.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.dropdown.setProps({});\n };\n\n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.dropdownContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.dropdown.state.isShown) return;\n this.dropdownContentTimeout = window.setTimeout(() => {\n this.dropdown.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.dropdown.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.dropdownContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bkdbdazhicpcsb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Message Type\",\n },\n });\n \n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ckpobpoksopivk\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dezswwocyeklua\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"chmgfdlhraeqpm\", function (event, $$0, $$1) {\n\n if ($$0)\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n content: $$1, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"xdhxtmugtkgre\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { capitalize: true });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"byalurfuuolqnr\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gytkemwcxjyjds\", function (event, $$0) {\n\n const dropdownMenuTarget = this.closest('[key=\"message--show--content-area\"]').querySelector('[key=\"message--show--content-area--dropdown-menu-target\"]');\n leafac.setTippy({\n event,\n element: dropdownMenuTarget,\n elementProperty: \"dropdownMenu\",\n tippyProps: {\n trigger: \"manual\",\n interactive: true,\n content: $$0, \n },\n });\n \n this.onmouseup = (event) => {\n window.setTimeout(() => {\n const selection = window.getSelection();\n const anchorElement = leafac.ancestors(selection.anchorNode).reverse().find(element => typeof element?.getAttribute?.(\"data-position\") === \"string\");\n const focusElement = leafac.ancestors(selection.focusNode).reverse().find(element => typeof element?.getAttribute?.(\"data-position\") === \"string\");\n if (\n selection.isCollapsed ||\n anchorElement === undefined ||\n focusElement === undefined ||\n !this.contains(anchorElement) ||\n !this.contains(focusElement) ||\n anchorElement.closest('[key^=\"poll/\"]') !== null ||\n focusElement.closest('[key^=\"poll/\"]') !== null\n ) return;\n dropdownMenuTarget.style.top = String(event.layerY) + \"px\";\n dropdownMenuTarget.style.left = String(event.layerX) + \"px\";\n dropdownMenuTarget.dropdownMenu.show();\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"blfzccfbnuobzo\", function (event, $$0, $$1, $$2) {\n\n this.onclick = () => {\n tippy.hideAll();\n const selection = window.getSelection();\n const anchorElement = leafac.ancestors(selection.anchorNode).reverse().find(element => typeof element?.getAttribute?.(\"data-position\") === \"string\");\n const focusElement = leafac.ancestors(selection.focusNode).reverse().find(element => typeof element?.getAttribute?.(\"data-position\") === \"string\");\n const contentElement = this.closest('[key=\"message--show--content-area\"]').querySelector('[key=\"message--show--content-area--content\"]');\n if (\n selection.isCollapsed ||\n anchorElement === undefined ||\n focusElement === undefined ||\n !contentElement.contains(anchorElement) ||\n !contentElement.contains(focusElement)\n ) return;\n const anchorPosition = JSON.parse(anchorElement.getAttribute(\"data-position\"));\n const focusPosition = JSON.parse(focusElement.getAttribute(\"data-position\"));\n const start = Math.min(anchorPosition.start.offset, focusPosition.start.offset);\n const end = Math.max(anchorPosition.end.offset, focusPosition.end.offset);\n const content = anchorElement.closest(\"[data-content-source]\").getAttribute(\"data-content-source\");\n const newMessage = document.querySelector('[key=\"new-message\"]');\n newMessage.querySelector('[key=\"content-editor--button--write\"]')?.click();\n const element = newMessage.querySelector('[key=\"content-editor--write--textarea\"]');\n textFieldEdit.wrapSelection(\n element,\n ((element.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"> \" + $$0 + \"#\" + $$1 + \"/\" + $$2 + \"\\n>\\n> \" + content.slice(start, end).replaceAll(\"\\n\", \"\\n> \") + \"\\n\\n\",\n \"\"\n );\n element.focus();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dkymqafsognewl\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"daopmduulsdciv\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"See course participants who liked\",\n },\n });\n \n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.dropdownContentTimeout);\n this.dropdownContentSkipLoading = false;\n \n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.dropdownContentTimeout);\n if (this.dropdownContentSkipLoading) return;\n this.dropdownContentSkipLoading = true;\n leafac.loadPartial(this.dropdown.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.dropdown.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.dropdown.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.dropdown.setProps({});\n };\n \n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.dropdownContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.dropdown.state.isShown) return;\n this.dropdownContentTimeout = window.setTimeout(() => {\n this.dropdown.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.dropdown.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.dropdownContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hbccbravsahvos\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.tooltipContentTimeout);\n this.tooltipContentSkipLoading = false;\n \n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.tooltipContentSkipLoading) return;\n this.tooltipContentSkipLoading = true;\n leafac.loadPartial(this.tooltip.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.tooltip.setProps({});\n };\n \n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.tooltip.state.isShown) return;\n this.tooltipContentTimeout = window.setTimeout(() => {\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.tooltipContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bmiajbegnaaquq\", function (event) {\n\n if (event?.detail?.liveUpdate && !this.closest('[key=\"message--edit\"]').hidden) return;\n this.partialParentElement = false;\n this.skipLoading = false;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"blczqoohbxwpxi\", function (event, $$0, $$1) {\n\n this.isModified = false;\n\n this.isUpdating ??= false;\n this.shouldUpdateAgain ??= false;\n this.oninput = async () => {\n if (this.isUpdating) {\n this.shouldUpdateAgain = true;\n return;\n }\n this.isUpdating = true;\n this.shouldUpdateAgain = false;\n await fetch($$0, {\n method: \"POST\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams(new FormData(this)),\n });\n this.isUpdating = false;\n if (this.shouldUpdateAgain) this.oninput();\n };\n\n this.onsubmit = () => {\n window.setTimeout(() => {\n const placeholder = document.querySelector('[key=\"message--new-message--placeholder\"]');\n const content = this.querySelector('[name=\"content\"]');\n if ($$1)\n placeholder.querySelector('[key=\"message--new-message--placeholder--anonymous--' + (!this.querySelector('[name=\"isAnonymous\"]').checked).toString() + '\"]').hidden = true;\n placeholder.querySelector('[key=\"message--new-message--placeholder--content\"]').textContent = content.value;\n placeholder.hidden = false;\n for (const element of leafac.ancestors(placeholder))\n element.scroll(0, element.scrollHeight);\n textFieldEdit.set(content, \"\");\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dodkxkdaoscsqa\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n\n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+enter\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eiaxptffaqjnfc\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ereyqdqjdlvllx\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hbqopjbpotoxox\", function (event, $$0) {\n\n this.isModified = false;\n\n this.onchange = async () => {\n await fetch($$0, {\n method: \"PATCH\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body: new URLSearchParams({ preferAnonymous: String(this.checked), }),\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"erlwokxgtxgqnf\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Anonymous to Other Students\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ktlweivjachnr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Signed by You\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dgioikqsvbszix\", function (event, $$0, $$1) {\n\n if ($$0) return;\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$1,\n },\n });\n \n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+enter\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"kbbglpbyfypll\", function (event, $$0, $$1) {\n\n if ($$0) return;\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$1,\n },\n });\n \n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n \n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+enter\", () => { this.click(); return false; });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ftgsdbnplrhmda\", function (event) {\n\n this.hidden = leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ezswsgcyeefeyw\", function (event) {\n\n this.hidden = !leafac.isAppleDevice;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dvpsjpvlesrzqn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"Course staff whispers are messages visible to the course staff only.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dkvovaewomhktd\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"To join an existing course you either have to follow an invitation link or be invited via email. Contact your course staff for more information.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gbcbzvxsmhxrjg\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dusbygeprytfrw\", function (event) {\n\n this.defaultValue = new Date().getFullYear().toString();\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dqiswarsgtzkqa\", function (event) {\n\n const month = new Date().getMonth() + 1;\n this.defaultValue = month < 4 || month > 9 ? \"Spring\" : \"Fall\";\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bkllcseeaixirf\", function (event, $$0, $$1, $$2, $$3) {\n\n this.style.setProperty(\"--color--accent-color--100\", $$0);\n this.style.setProperty(\"--color--accent-color--200\", $$1);\n this.style.setProperty(\"--color--accent-color--700\", $$2);\n this.style.setProperty(\"--color--accent-color--800\", $$3);\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ckvwmowchsgjdq\", function (event) {\n\n this.onclick = () => {\n for (const element of leafac.nextSiblings(this).slice(1))\n element.hidden = !element.hidden;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fjdhjqofaiiprv\", function (event) {\n\n this.isModified = true;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dyzsbfyygmptao\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Visible by Course Staff Only\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dnpbgmnhwmctga\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Visible by Everyone\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"pqgiejeqtqoyp\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Remove Tag\",\n },\n });\n\n if ($$0)\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n content: $$1, \n },\n });\n else\n this.onclick = () => {\n const tags = this.closest('[key=\"tags\"]');\n this.closest('[key^=\"tag/\"]').remove();\n tags.reorder();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"tohikuxnwzxkt\", function (event) {\n\n this.onclick = () => {\n const tag = this.closest('[key^=\"tag/\"]');\n tag.classList.add(\"removed\");\n for (const element of leafac.descendants(tag)) {\n if (element.skipDisable === true) continue;\n if (typeof element.disabled === \"boolean\") element.disabled = true;\n if (element.matches(\".button\")) element.classList.add(\"disabled\");\n if (element.tooltip !== undefined) element.tooltip.disable();\n }\n this.closest('[key=\"tags\"]').reorder();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dqgwqbchycszkn\", function (event) {\n\n this.skipDisable = true;\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Don\u2019t Remove Tag\",\n },\n });\n\n this.onclick = () => {\n const tag = this.closest('[key^=\"tag/\"]');\n tag.classList.remove(\"removed\");\n for (const element of leafac.descendants(tag)) {\n if (typeof element.disabled === \"boolean\") element.disabled = false;\n if (element.matches(\".button\")) element.classList.remove(\"disabled\");\n if (element.tooltip !== undefined) element.tooltip.enable();\n }\n tag.closest('[key=\"tags\"]').reorder();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"zosdkinxejuor\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"See Conversations with This Tag\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ddqllapnltbski\", function (event) {\n\n this.onbeforemorph = (event) => {\n const liveUpdate = event?.detail?.liveUpdate;\n if (!liveUpdate) this.isModified = false;\n return !liveUpdate;\n };\n\n this.onpointerdown = (event) => {\n if (event.target.closest('[key=\"tag--grab--handle\"]') === null) return;\n\n const body = document.querySelector(\"body\");\n const tag = event.target.closest('[key^=\"tag/\"]');\n\n this.grabbed = tag;\n body.classList.add(\"grabbing\");\n tag.classList.add(\"grabbed\");\n\n body.addEventListener(\"pointerup\", () => {\n delete this.grabbed;\n body.classList.remove(\"grabbing\");\n tag.classList.remove(\"grabbed\");\n }, { once: true });\n };\n\n this.onpointermove = (event) => {\n const tag = (\n event.pointerType === \"touch\" ? document.elementFromPoint(event.clientX, event.clientY) : event.target\n ).closest('[key^=\"tag/\"]');\n if (tag === null || [undefined, tag].includes(this.grabbed)) return;\n\n const boundingClientRect = tag.getBoundingClientRect();\n tag[\n (event.clientY - boundingClientRect.top) / (boundingClientRect.bottom - boundingClientRect.top) < 0.5 ?\n \"after\" : \"before\"\n ](this.grabbed);\n this.reorder();\n };\n\n this.onkeydown = (event) => {\n if (event.target.closest('[key=\"tag--grab--handle\"]') === null) return;\n\n const tag = event.target.closest('[key^=\"tag/\"]');\n switch (event.code) {\n case \"ArrowUp\":\n event.preventDefault();\n tag.previousElementSibling?.before?.(tag);\n break;\n case \"ArrowDown\":\n event.preventDefault();\n tag.nextElementSibling?.after?.(tag);\n break;\n }\n tag.querySelector('[key=\"tag--grab--handle\"]').focus();\n this.reorder();\n };\n\n this.reorder = () => {\n this.isModified = true;\n\n for (const [order, tag] of this.querySelectorAll('[key^=\"tag/\"]:not(.removed)').entries())\n for (const element of tag.querySelectorAll('[name^=\"tags[\"]'))\n element.setAttribute(\"name\", element.getAttribute(\"name\").replace(/\\d+/, String(order)));\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"flbxprgiqrtald\", function (event, $$0) {\n\n this.onclick = () => {\n const newTag = leafac.stringToElement($$0).querySelector('[key=\"tag/new\"]');\n\n const tags = this.closest(\"form\").querySelector('[key=\"tags\"]');\n tags.insertAdjacentElement(\"beforeend\", newTag);\n leafac.execute({ element: newTag });\n tags.reorder();\n };\n\n this.onvalidate = () => {\n if (this.closest(\"form\").querySelector('[key=\"tags\"]').children.length === 0)\n return \"Please add at least one tag.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ecgjtrjiduumye\", function (event) {\n\n this.onchange = () => {\n const form = this.closest(\"form\");\n const emails = form.querySelector('[key=\"emails\"]');\n emails.hidden = true;\n for (const element of leafac.descendants(emails))\n if (element.disabled !== undefined) element.disabled = true;\n form.querySelector('[key=\"button--create-invitation\"]').hidden = false;\n form.querySelector('[key=\"button--send-invitation-emails\"]').hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ewmzyemenadwhr\", function (event) {\n\n this.onchange = () => {\n const form = this.closest(\"form\");\n const emails = form.querySelector('[key=\"emails\"]');\n emails.hidden = false;\n for (const element of leafac.descendants(emails))\n if (element.disabled !== undefined) element.disabled = false;\n form.querySelector('[key=\"button--create-invitation\"]').hidden = true;\n form.querySelector('[key=\"button--send-invitation-emails\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hhwzsaolgesynb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ezwaxjjnwfyfii\", function (event) {\n\n this.onvalidate = () => {\n const emails = [];\n for (let email of this.value.split(/[,\\n]/)) {\n email = email.trim();\n let name = null;\n const match = email.match(/^(?.*)<(?.*)>$/);\n if (match !== null) {\n email = match.groups.email.trim();\n name = match.groups.name.trim();\n if (name.startsWith('\"') && name.endsWith('\"'))\n name = name.slice(1, -1);\n if (name === \"\") name = null;\n }\n if (email === \"\") continue;\n emails.push({ email, name });\n }\n if (\n emails.length === 0 ||\n emails.some(\n ({ email }) => email.match(leafac.regExps.email) === null\n )\n )\n return \"Match the requested format.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bmjfumglnvstqt\", function (event) {\n\n this.onchange = () => {\n const expiresAt = this.closest(\"form\").querySelector('[key=\"expires-at\"]');\n expiresAt.hidden = !this.checked;\n for (const element of leafac.descendants(expiresAt))\n if (element.disabled !== undefined) element.disabled = !this.checked;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gbiyabexqzmdfn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Expiring\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"etfxqrnrzaqxxa\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Set as Not Expiring\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dzhwmvwptlvtub\", function (event) {\n\n this.value = this.defaultValue = leafac.localizeDateTime(this.defaultValue);\n\n this.onvalidate = () => {\n const error = leafac.validateLocalizedDateTime(this);\n if (typeof error === \"string\") return error;\n if (new Date(this.value).getTime() <= Date.now()) return \"Must be in the future.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"edwdoptjvtnfdt\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Invitation Link\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dkpkclitnwcpqw\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Invitation Email\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fchrefbxqxsreu\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"See Invitation Link\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n maxWidth: \"none\",\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"snsaejadcmuqh\", function (event) {\n\n this.onfocus = () => {\n this.select();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cghbtykslaigkh\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Copy Link\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n const stickies = this.querySelector('[key=\"stickies\"]');\n const check = this.querySelector('[key=\"check\"]');\n stickies.hidden = true;\n check.hidden = false;\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n stickies.hidden = false;\n check.hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bfjetetfptmzsl\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"See QR Code for Link\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cieopjferotuxs\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eisoalousyfmiu\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not resend this invitation because it\u2019s used.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"deiqiqsduqtmus\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not resend this invitation because it\u2019s expired.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cinauyfystpoed\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Course Role\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fzvduqpicemexn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not update the course role of this invitation because it\u2019s used.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gkcjvjklbemwnm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not update the course role of this invitation because it\u2019s expired.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"goczgnhhilvexe\", function (event) {\n\n this.value = this.defaultValue = leafac.localizeDateTime(this.defaultValue);\n\n this.onvalidate = () => {\n const error = leafac.validateLocalizedDateTime(this);\n if (typeof error === \"string\") return error;\n if (new Date(this.value).getTime() <= Date.now()) return \"Must be in the future.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ouubxppovpcyv\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n interactive: true,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ggfjeqisfnvgea\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bifghjgomepmvb\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Expiration\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cxxyhlxqiytzgm\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"farskcelhbmnqd\", function (event, $$0) {\n\n this.onclick = () => {\n tippy.hideAll();\n const button = document.querySelector($$0);\n button.click();\n button.tooltip.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"qqsyneauakcug\", function (event) {\n\n this.onfocus = () => {\n this.select();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgcmogqgpuxyue\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Copy Link\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n const stickies = this.querySelector('[key=\"stickies\"]');\n const check = this.querySelector('[key=\"check\"]');\n stickies.hidden = true;\n check.hidden = false;\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n stickies.hidden = false;\n check.hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cmmfvnfbuznftm\", function (event) {\n\n this.isModified = false;\n\n this.oninput = () => {\n const filterPhrases = this.value.split(/[^a-z0-9]+/i).filter((filterPhrase) => filterPhrase.trim() !== \"\");\n for (const courseParticipant of document.querySelectorAll('[key^=\"course-participant/\"]')) {\n let courseParticipantHidden = filterPhrases.length > 0;\n for (const filterablePhrasesElement of courseParticipant.querySelectorAll(\"[data-filterable-phrases]\")) {\n const filterablePhrases = JSON.parse(filterablePhrasesElement.getAttribute(\"data-filterable-phrases\"));\n const filterablePhrasesElementChildren = [];\n for (const filterablePhrase of filterablePhrases) {\n let filterablePhraseElement;\n if (filterPhrases.some(filterPhrase => filterablePhrase.toLowerCase().startsWith(filterPhrase.toLowerCase()))) {\n filterablePhraseElement = document.createElement(\"mark\");\n filterablePhraseElement.classList.add(\"mark\");\n courseParticipantHidden = false;\n } else\n filterablePhraseElement = document.createElement(\"span\");\n filterablePhraseElement.textContent = filterablePhrase;\n filterablePhrasesElementChildren.push(filterablePhraseElement);\n }\n filterablePhrasesElement.replaceChildren(...filterablePhrasesElementChildren);\n }\n courseParticipant.hidden = courseParticipantHidden;\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"geqwjlvubitcxk\", function (event) {\n\n this.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gmzcmjfdaeqpbs\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Copy Email\",\n },\n });\n\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"copied\",\n tippyProps: {\n theme: \"green\",\n trigger: \"manual\",\n content: \"Copied\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n this.copied.show();\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n this.copied.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dzwmfrppzjzrmp\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Course Role\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bqdaojwrtoefts\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not update your own course role because you\u2019re the only course staff member.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cvfnoskjymurkv\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n appendTo: document.querySelector(\"body\"),\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cernxzzmsvoqpn\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Remove from the Course\",\n },\n });\n\n if ($$0)\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n content: \"You may not remove yourself from the course because you\u2019re the only course staff member.\",\n },\n });\n else\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n content: $$1, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cslspnctqfqyqg\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"A bar with the accent color appears at the top of pages related to this course to help you differentiate between courses.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"erlhqbrimvomxx\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"You must confirm the course name to avoid removing yourself from the wrong course by accident.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bhjppcvhtjgtnm\", function (event, $$0) {\n\n this.onvalidate = () => {\n if (this.value !== $$0)\n return \"Please confirm the course name.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cqcnmtmvdhpwcq\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n onShow: () => leafac.validate(this.closest(\"form\")),\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ffecemskjvupzw\", function (event) {\n\n this.onclick = () => {\n document.querySelector('[key=\"update-email\"]').hidden = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"etttlyxlvljulz\", function (event) {\n\n this.onvalidate = () => {\n if (!leafac.isModified(this))\n return \"Please provide the email address to which you\u2019d like to update.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dxlhguzbjtvzpm\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"You must confirm your password because this is an important operation that affects your account.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"beqrxmxfwbrlpo\", function (event, $$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7) {\n\n if ($$0) {\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"flash\",\n tippyProps: {\n appendTo: this,\n trigger: \"manual\",\n hideOnClick: false,\n theme: $$1,\n arrow: false,\n interactive: true,\n content: $$2, \n },\n });\n this.flash.show();\n }\n\n document.querySelector('[key=\"theme-color--light\"]').setAttribute(\"content\", getComputedStyle(document.documentElement).getPropertyValue($$3));\n document.querySelector('[key=\"theme-color--dark\"]').setAttribute(\"content\", getComputedStyle(document.documentElement).getPropertyValue($$4));\n\n if ($$5 && event?.detail?.liveUpdate !== true)\n leafac.liveConnection({\n nonce: $$6,\n newServerVersionMessage: \"Courselore has been updated. Please reload the page.\",\n offlineMessage: \"Failed to connect to Courselore. Please check your internet connection and try reloading the page.\",\n environment: $$7,\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dywqanxkmdldcf\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: $$0,\n touch: false,\n content: \"Close\",\n },\n });\n\n this.onclick = () => {\n this.closest(\"[data-tippy-root]\")._tippy.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ejhssnuiwtweya\", function (event) {\n\n this.onscroll = () => {\n this.scroll(0, 0);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ezbjiixfhsnljj\", function (event, $$0, $$1, $$2) {\n\n this.style.setProperty(\"--color--accent-color--500\", $$0);\n this.style.setProperty(\"--color--accent-color--600\", $$1);\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"What\u2019s This?\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$2, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hacllyowdvxyhg\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eqvvpizcazzbgg\", function (event, $$0) {\n\n this.onclick = async () => {\n this.classList.add(\"button--amber\");\n await new Promise((resolve) => { window.setTimeout(resolve, 3 * 1000); });\n await fetch($$0, { cache: \"no-store\" });\n this.classList.remove(\"button--amber\");\n this.classList.add(\"button--green\");\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gnnqxvgecfrwjf\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Courselore\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eweaghxozpbicr\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fppczrxbcrtwpg\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0, \n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$1, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fcqvseayqawrdx\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"To join an existing course you either have to follow an invitation link or be invited via email. Contact your course staff for more information.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dfzadgbvpgypff\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$1, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"kwuqkzkhgwnfd\", function (event) {\n\n if (\n event?.detail?.previousLocation?.origin !== window.location.origin ||\n event?.detail?.previousLocation?.pathname !== window.location.pathname ||\n event?.detail?.previousLocation?.search !== window.location.search\n )\n this.scroll(0, 0);\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"qoynnnqxqpeyz\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"higtjgtkqelahz\", function (event, $$0, $$1, $$2) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0,\n },\n });\n\n if ($$1)\n this.onclick = async () => {\n this.classList.remove(\"strong\");\n this.classList.remove(\"text--green\");\n await fetch($$2, {\n method: \"PATCH\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n });\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fbalyzfiaivaxo\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hhzhxrhkvszqzf\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Current Courselore version\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"uieeewhvaeak\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Latest Courselore version\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cgcilkkehvukfz\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Loading\u2026\",\n },\n });\n\n window.onlivenavigate = () => {\n const parentElement = this;\n parentElement.hidden = false;\n const element = parentElement.querySelector(\"div\");\n let width = 5;\n window.clearTimeout(element.updateTimeout);\n (function update() {\n if (parentElement.hidden || !leafac.isConnected(element)) return;\n element.style.width = width.toString() + \"%\";\n width += (95 - width) / (20 + Math.random() * 15);\n element.updateTimeout = window.setTimeout(update, 200 + Math.random() * 300);\n })();\n };\n\n window.onlivenavigateerror = () => {\n this.hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fypjycvudynjzs\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n content: $$0,\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eldgejeerlegmx\", function (event, $$0, $$1, $$2) {\n\n this.onclick = () => {\n const content = this.closest(\"[data-content-source]\").getAttribute(\"data-content-source\");\n const newMessage = document.querySelector('[key=\"new-message\"]');\n newMessage.querySelector('[key=\"content-editor--button--write\"]')?.click();\n const element = newMessage.querySelector('[key=\"content-editor--write--textarea\"]');\n textFieldEdit.wrapSelection(\n element,\n ((element.selectionStart > 0) ? \"\\n\\n\" : \"\") + \"> \" + $$0 + \"#\" + $$1 + \"/\" + $$2 + \"\\n>\\n> \" + content.replaceAll(\"\\n\", \"\\n> \") + \"\\n\\n\",\n \"\"\n );\n element.focus();\n tippy.hideAll();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cyaxlmqkldmthd\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.tooltipContentTimeout);\n this.tooltipContentSkipLoading = false;\n \n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.tooltipContentSkipLoading) return;\n this.tooltipContentSkipLoading = true;\n leafac.loadPartial(this.tooltip.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.tooltip.setProps({});\n };\n \n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.tooltip.state.isShown) return;\n this.tooltipContentTimeout = window.setTimeout(() => {\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.tooltipContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dvrisunlgxwtth\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"copied\",\n tippyProps: {\n theme: \"green\",\n trigger: \"manual\",\n content: \"Copied\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n this.copied.show();\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n this.copied.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"dklrdlooqpeszl\", function (event, $$0) {\n\n this.onmouseenter = this.onfocus = async () => {\n const messageEdit = this.closest('[key^=\"message/\"]').querySelector('[key=\"message--edit\"]');\n const messageEditForm = messageEdit.querySelector('[key=\"form\"]');\n if (messageEditForm.skipLoading === true) return;\n messageEditForm.skipLoading = true;\n leafac.loadPartial(messageEditForm, await (await fetch($$0, { cache: \"no-store\" })).text());\n messageEdit.querySelector('[key=\"loading\"]').hidden = true;\n messageEdit.querySelector('[key=\"form\"]').hidden = false;\n autosize.update(this.closest('[key^=\"message/\"]')?.querySelector('[key=\"message--edit\"] [key=\"content-editor--write--textarea\"]'));\n };\n\n this.onclick = () => {\n this.closest('[key^=\"message/\"]').querySelector('[key=\"message--show\"]').hidden = true;\n this.closest('[key^=\"message/\"]').querySelector('[key=\"message--edit\"]').hidden = false;\n autosize.update(this.closest('[key^=\"message/\"]').querySelector('[key=\"message--edit\"] [key=\"content-editor--write--textarea\"]'));\n tippy.hideAll();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"giuzswqgycvakj\", function (event, $$0, $$1) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n interactive: true,\n onHidden: () => { this.onmouseleave(); },\n content: $$0,\n },\n });\n\n window.clearTimeout(this.tooltipContentTimeout);\n this.tooltipContentSkipLoading = false;\n\n this.onmouseenter = this.onfocus = async () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.tooltipContentSkipLoading) return;\n this.tooltipContentSkipLoading = true;\n leafac.loadPartial(this.tooltip.props.content.querySelector('[key=\"content\"]'), await (await fetch($$1, { cache: \"no-store\" })).text());\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = true;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = false;\n this.tooltip.setProps({});\n };\n\n this.onmouseleave = this.onblur = () => {\n window.clearTimeout(this.tooltipContentTimeout);\n if (this.matches(\":hover, :focus-within\") || this.tooltip.state.isShown) return;\n this.tooltipContentTimeout = window.setTimeout(() => {\n this.tooltip.props.content.querySelector('[key=\"loading\"]').hidden = false;\n this.tooltip.props.content.querySelector('[key=\"content\"]').hidden = true;\n this.tooltipContentSkipLoading = false;\n }, 60 * 1000);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"psvvjvvimzgbr\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cxgapmycafabdw\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: $$0,\n },\n });\n\n const textarea = this.closest(\"form\").querySelector('[key=\"content-editor--write--textarea\"]');\n\n (textarea.mousetrap ??= new Mousetrap(textarea)).bind(\"mod+enter\", () => { this.click(); return false; }); \n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"btzbudshvpzvgr\", function (event) {\n\n this.onclick = () => {\n this.closest('[key^=\"message/\"]').querySelector('[key=\"message--show\"]').hidden = false;\n this.closest('[key^=\"message/\"]').querySelector('[key=\"message--edit\"]').hidden = true;\n\n const messageEdit = this.closest('[key^=\"message/\"]').querySelector('[key=\"message--edit\"]');\n messageEdit.querySelector('[key=\"loading\"]').hidden = false;\n messageEdit.querySelector('[key=\"form\"]').hidden = true;\n messageEdit.querySelector('[key=\"form\"]').skipLoading = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hkukksaegmmhlf\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { capitalize: true });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cvliezdzbtbocr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Online\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bgzcbvbynutepb\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Course Staff\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"pgxzmipiutgsw\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n interactive: true,\n appendTo: document.querySelector(\"body\"),\n delay: [1000, null],\n touch: [\"hold\", 1000],\n content: $$0, \n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fixgnebnaykheh\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Copy Email\",\n },\n });\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"copied\",\n tippyProps: {\n theme: \"green\",\n trigger: \"manual\",\n content: \"Copied\",\n },\n });\n\n this.onclick = async () => {\n await navigator.clipboard.writeText($$0);\n this.copied.show();\n await new Promise((resolve) => { window.setTimeout(resolve, 1000); });\n this.copied.hide();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hfwybvdquqrale\", function (event) {\n\n leafac.relativizeDateTimeElement(this, { preposition: \"on\", target: this.parentElement });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bdiypnbetmedhr\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Anonymous to Other Students\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"epcssncdycxbjm\", function (event) {\n\n this.dragLevel = 0;\n this.ondragenter = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n if (this.dragLevel === 0) this.classList.add(\"drag\");\n this.dragLevel++;\n };\n this.ondragleave = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n this.dragLevel--;\n if (this.dragLevel === 0) this.classList.remove(\"drag\");\n };\n this.ondragover = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n };\n this.ondrop = (event) => {\n if (!event.dataTransfer.types.includes(\"Files\")) return;\n event.preventDefault();\n this.classList.remove(\"drag\");\n this.dragLevel = 0;\n const fileList = [...event.dataTransfer.items].flatMap((item) => item.webkitGetAsEntry()?.isFile ?? true ? [item.getAsFile()] : []);\n if (fileList.length > 0)\n this.querySelector('[key=\"avatar-chooser--upload\"]').upload(fileList);\n };\n\n this.onbeforemorph = (event) => !event?.detail?.liveUpdate;\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"hboxfjqxqpyfji\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Add Avatar\",\n },\n });\n\n this.onclick = () => {\n this.closest(\"form\").querySelector('[key=\"avatar-chooser--upload\"]').click();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"eejwmcnwmyrrgj\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n touch: false,\n content: \"Update Avatar\",\n },\n });\n\n this.onclick = () => {\n this.closest(\"form\").querySelector('[key=\"avatar-chooser--upload\"]').click();\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fswslmlqyyyth\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n theme: \"rose\",\n touch: false,\n content: \"Remove Avatar\",\n },\n });\n \n this.onclick = () => {\n const form = this.closest(\"form\");\n const avatar = form.querySelector('[name=\"avatar\"]')\n avatar.value = \"\";\n form.querySelector('[key=\"avatar-chooser--empty\"]').hidden = false;\n form.querySelector('[key=\"avatar-chooser--filled\"]').hidden = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"wvqxzhwuncjux\", function (event, $$0, $$1) {\n\n this.isModified = false;\n\n const avatarChooser = this.closest('[key=\"avatar-chooser\"]');\n const avatar = avatarChooser.querySelector('[name=\"avatar\"]');\n const avatarEmpty = avatarChooser.querySelector('[key=\"avatar-chooser--empty\"]');\n const avatarFilled = avatarChooser.querySelector('[key=\"avatar-chooser--filled\"]');\n\n leafac.setTippy({\n event,\n element: avatarChooser,\n elementProperty: \"uploadingIndicator\",\n tippyProps: {\n trigger: \"manual\",\n hideOnClick: false,\n content: $$0,\n },\n });\n\n this.upload = async (fileList) => {\n const body = new FormData();\n body.append(\"avatar\", fileList[0]);\n this.value = \"\";\n tippy.hideAll();\n avatarChooser.uploadingIndicator.show();\n const response = await fetch($$1, {\n method: \"POST\",\n headers: { \"CSRF-Protection\": \"true\", },\n cache: \"no-store\",\n body,\n });\n avatarChooser.uploadingIndicator.hide();\n if (!response.ok) {\n leafac.setTippy({\n element: avatarChooser,\n elementProperty: \"uploadingError\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"manual\",\n content: await response.text(),\n },\n });\n avatarChooser.uploadingError.show();\n return;\n }\n const avatarURL = await response.text();\n avatar.value = avatarURL;\n avatarEmpty.hidden = true;\n avatarFilled.hidden = false;\n avatarFilled.querySelector(\"img\").setAttribute(\"src\", avatarURL);\n };\n\n this.onchange = () => {\n this.upload(this.files);\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"ceqraednhaojns\", function (event) {\n\n this.onvalidate = () => {\n if (!leafac.isModified(this))\n return \"Please provide the email address to which you\u2019d like to update.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"sgkuubrrvxpgh\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"You must confirm your password because this is an important operation that affects your account.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"btbddaoktloydh\", function (event) {\n\n this.onvalidate = () => {\n if (this.value !== this.closest(\"form\").querySelector('[name=\"newPassword\"]').value)\n return \"New Password & New Password Confirmation don\u2019t match.\";\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"fqmffyedwppxuj\", function (event) {\n\n this.onchange = () => {\n if (this.checked) {\n this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForMentions\"]').checked = true;\n this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForMessagesInConversationsInWhichYouParticipated\"]').checked = true;\n this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForMessagesInConversationsYouStarted\"]').checked = true;\n }\n for (const element of this.closest(\"form\").querySelectorAll('[name=\"emailNotificationsForAllMessages\"]')) {\n element.disabled = !this.checked;\n element.closest(\"label\").classList[this.checked ? \"remove\" : \"add\"](\"disabled\");\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gqzkuxyhivpwpr\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) {\n const element = this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForAllMessages\"]');\n element.checked = false;\n element.onchange();\n }\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gecqgxqajdeech\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) {\n const element = this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForAllMessages\"]');\n element.checked = false;\n element.onchange();\n }\n if (this.checked) this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForMessagesInConversationsYouStarted\"]').checked = true;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"gydomzxwjwbjkh\", function (event) {\n\n this.onchange = () => {\n if (!this.checked) {\n const element = this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForAllMessages\"]');\n element.checked = false;\n element.onchange();\n }\n if (!this.checked) this.closest(\"form\").querySelector('[name=\"isEmailNotificationsForMessagesInConversationsInWhichYouParticipated\"]').checked = false;\n };\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"cypkltevryuiqn\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n content: \"You always receive email notifications for course staff announcements.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"bhcwuipqzysfgl\", function (event) {\n\n leafac.setTippy({\n event,\n element: this,\n tippyProps: {\n trigger: \"click\",\n content: \"You must confirm your email because this is an important operation that affects your account.\",\n },\n });\n });\n\n/********************************************************************************/\n\nleafac.execute.functions.set(\"efkrhudqtuboju\", function (event, $$0) {\n\n leafac.setTippy({\n event,\n element: this,\n elementProperty: \"dropdown\",\n tippyProps: {\n theme: \"rose\",\n trigger: \"click\",\n interactive: true,\n content: $$0, \n },\n });\n });\n\n", "// Compute what scrolling needs to be done on required scrolling boxes for target to be in view\n\n// The type names here are named after the spec to make it easier to find more information around what they mean:\n// To reduce churn and reduce things that need be maintained things from the official TS DOM library is used here\n// https://drafts.csswg.org/cssom-view/\n\n// For a definition on what is \"block flow direction\" exactly, check this: https://drafts.csswg.org/css-writing-modes-4/#block-flow-direction\n\n/**\n * This new option is tracked in this PR, which is the most likely candidate at the time: https://github.com/w3c/csswg-drafts/pull/1805\n * @public\n */\nexport type ScrollMode = 'always' | 'if-needed'\n\n/** @public */\nexport interface Options {\n /**\n * Control the logical scroll position on the y-axis. The spec states that the `block` direction is related to the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode), but this is not implemented yet in this library.\n * This means that `block: 'start'` aligns to the top edge and `block: 'end'` to the bottom.\n * @defaultValue 'center'\n */\n block?: ScrollLogicalPosition\n /**\n * Like `block` this is affected by the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode). In left-to-right pages `inline: 'start'` will align to the left edge. In right-to-left it should be flipped. This will be supported in a future release.\n * @defaultValue 'nearest'\n */\n inline?: ScrollLogicalPosition\n /**\n * This is a proposed addition to the spec that you can track here: https://github.com/w3c/csswg-drafts/pull/5677\n *\n * This library will be updated to reflect any changes to the spec and will provide a migration path.\n * To be backwards compatible with `Element.scrollIntoViewIfNeeded` if something is not 100% visible it will count as \"needs scrolling\". If you need a different visibility ratio your best option would be to implement an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).\n * @defaultValue 'always'\n */\n scrollMode?: ScrollMode\n /**\n * By default there is no boundary. All the parent elements of your target is checked until it reaches the viewport ([`document.scrollingElement`](https://developer.mozilla.org/en-US/docs/Web/API/document/scrollingElement)) when calculating layout and what to scroll.\n * By passing a boundary you can short-circuit this loop depending on your needs:\n * \n * - Prevent the browser window from scrolling.\n * - Scroll elements into view in a list, without scrolling container elements.\n * \n * You can also pass a function to do more dynamic checks to override the scroll scoping:\n * \n * ```js\n * let actions = compute(target, {\n * boundary: (parent) => {\n * // By default `overflow: hidden` elements are allowed, only `overflow: visible | clip` is skipped as\n * // this is required by the CSSOM spec\n * if (getComputedStyle(parent)['overflow'] === 'hidden') {\n * return false\n * }\n\n * return true\n * },\n * })\n * ```\n * @defaultValue null\n */\n boundary?: Element | ((parent: Element) => boolean) | null\n /**\n * New option that skips auto-scrolling all nodes with overflow: hidden set\n * See FF implementation: https://hg.mozilla.org/integration/fx-team/rev/c48c3ec05012#l7.18\n * @defaultValue false\n * @public\n */\n skipOverflowHiddenElements?: boolean\n}\n\n/** @public */\nexport interface ScrollAction {\n el: Element\n top: number\n left: number\n}\n\n// @TODO better shadowdom test, 11 = document fragment\nconst isElement = (el: any): el is Element =>\n typeof el === 'object' && el != null && el.nodeType === 1\n\nconst canOverflow = (\n overflow: string | null,\n skipOverflowHiddenElements?: boolean\n) => {\n if (skipOverflowHiddenElements && overflow === 'hidden') {\n return false\n }\n\n return overflow !== 'visible' && overflow !== 'clip'\n}\n\nconst getFrameElement = (el: Element) => {\n if (!el.ownerDocument || !el.ownerDocument.defaultView) {\n return null\n }\n\n try {\n return el.ownerDocument.defaultView.frameElement\n } catch (e) {\n return null\n }\n}\n\nconst isHiddenByFrame = (el: Element): boolean => {\n const frame = getFrameElement(el)\n if (!frame) {\n return false\n }\n\n return (\n frame.clientHeight < el.scrollHeight || frame.clientWidth < el.scrollWidth\n )\n}\n\nconst isScrollable = (el: Element, skipOverflowHiddenElements?: boolean) => {\n if (el.clientHeight < el.scrollHeight || el.clientWidth < el.scrollWidth) {\n const style = getComputedStyle(el, null)\n return (\n canOverflow(style.overflowY, skipOverflowHiddenElements) ||\n canOverflow(style.overflowX, skipOverflowHiddenElements) ||\n isHiddenByFrame(el)\n )\n }\n\n return false\n}\n/**\n * Find out which edge to align against when logical scroll position is \"nearest\"\n * Interesting fact: \"nearest\" works similarily to \"if-needed\", if the element is fully visible it will not scroll it\n *\n * Legends:\n * ┌────────┐ ┏ ━ ━ ━ ┓\n * │ target │ frame\n * └────────┘ ┗ ━ ━ ━ ┛\n */\nconst alignNearest = (\n scrollingEdgeStart: number,\n scrollingEdgeEnd: number,\n scrollingSize: number,\n scrollingBorderStart: number,\n scrollingBorderEnd: number,\n elementEdgeStart: number,\n elementEdgeEnd: number,\n elementSize: number\n) => {\n /**\n * If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B\n *\n * ┌──┐\n * ┏━│━━│━┓\n * │ │\n * ┃ │ │ ┃ do nothing\n * │ │\n * ┗━│━━│━┛\n * └──┘\n *\n * If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D\n *\n * ┏ ━ ━ ━ ━ ┓\n * ┌───────────┐\n * │┃ ┃│ do nothing\n * └───────────┘\n * ┗ ━ ━ ━ ━ ┛\n */\n if (\n (elementEdgeStart < scrollingEdgeStart &&\n elementEdgeEnd > scrollingEdgeEnd) ||\n (elementEdgeStart > scrollingEdgeStart && elementEdgeEnd < scrollingEdgeEnd)\n ) {\n return 0\n }\n\n /**\n * If element edge A is outside scrolling box edge A and element height is less than scrolling box height\n *\n * ┌──┐\n * ┏━│━━│━┓ ┏━┌━━┐━┓\n * └──┘ │ │\n * from ┃ ┃ to ┃ └──┘ ┃\n *\n * ┗━ ━━ ━┛ ┗━ ━━ ━┛\n *\n * If element edge B is outside scrolling box edge B and element height is greater than scrolling box height\n *\n * ┏━ ━━ ━┓ ┏━┌━━┐━┓\n * │ │\n * from ┃ ┌──┐ ┃ to ┃ │ │ ┃\n * │ │ │ │\n * ┗━│━━│━┛ ┗━│━━│━┛\n * │ │ └──┘\n * │ │\n * └──┘\n *\n * If element edge C is outside scrolling box edge C and element width is less than scrolling box width\n *\n * from to\n * ┏ ━ ━ ━ ━ ┓ ┏ ━ ━ ━ ━ ┓\n * ┌───┐ ┌───┐\n * │ ┃ │ ┃ ┃ │ ┃\n * └───┘ └───┘\n * ┗ ━ ━ ━ ━ ┛ ┗ ━ ━ ━ ━ ┛\n *\n * If element edge D is outside scrolling box edge D and element width is greater than scrolling box width\n *\n * from to\n * ┏ ━ ━ ━ ━ ┓ ┏ ━ ━ ━ ━ ┓\n * ┌───────────┐ ┌───────────┐\n * ┃ │ ┃ │ ┃ ┃ │\n * └───────────┘ └───────────┘\n * ┗ ━ ━ ━ ━ ┛ ┗ ━ ━ ━ ━ ┛\n */\n if (\n (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize) ||\n (elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize)\n ) {\n return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart\n }\n\n /**\n * If element edge B is outside scrolling box edge B and element height is less than scrolling box height\n *\n * ┏━ ━━ ━┓ ┏━ ━━ ━┓\n *\n * from ┃ ┃ to ┃ ┌──┐ ┃\n * ┌──┐ │ │\n * ┗━│━━│━┛ ┗━└━━┘━┛\n * └──┘\n *\n * If element edge A is outside scrolling box edge A and element height is greater than scrolling box height\n *\n * ┌──┐\n * │ │\n * │ │ ┌──┐\n * ┏━│━━│━┓ ┏━│━━│━┓\n * │ │ │ │\n * from ┃ └──┘ ┃ to ┃ │ │ ┃\n * │ │\n * ┗━ ━━ ━┛ ┗━└━━┘━┛\n *\n * If element edge C is outside scrolling box edge C and element width is greater than scrolling box width\n *\n * from to\n * ┏ ━ ━ ━ ━ ┓ ┏ ━ ━ ━ ━ ┓\n * ┌───────────┐ ┌───────────┐\n * │ ┃ │ ┃ │ ┃ ┃\n * └───────────┘ └───────────┘\n * ┗ ━ ━ ━ ━ ┛ ┗ ━ ━ ━ ━ ┛\n *\n * If element edge D is outside scrolling box edge D and element width is less than scrolling box width\n *\n * from to\n * ┏ ━ ━ ━ ━ ┓ ┏ ━ ━ ━ ━ ┓\n * ┌───┐ ┌───┐\n * ┃ │ ┃ │ ┃ │ ┃\n * └───┘ └───┘\n * ┗ ━ ━ ━ ━ ┛ ┗ ━ ━ ━ ━ ┛\n *\n */\n if (\n (elementEdgeEnd > scrollingEdgeEnd && elementSize < scrollingSize) ||\n (elementEdgeStart < scrollingEdgeStart && elementSize > scrollingSize)\n ) {\n return elementEdgeEnd - scrollingEdgeEnd + scrollingBorderEnd\n }\n\n return 0\n}\n\nconst getParentElement = (element: Node): Element | null => {\n const parent = element.parentElement\n if (parent == null) {\n return (element.getRootNode() as ShadowRoot).host || null\n }\n return parent\n}\n\n/** @public */\nexport const compute = (target: Element, options: Options): ScrollAction[] => {\n if (typeof document === 'undefined') {\n // If there's no DOM we assume it's not in a browser environment\n return []\n }\n\n const { scrollMode, block, inline, boundary, skipOverflowHiddenElements } =\n options\n // Allow using a callback to check the boundary\n // The default behavior is to check if the current target matches the boundary element or not\n // If undefined it'll check that target is never undefined (can happen as we recurse up the tree)\n const checkBoundary =\n typeof boundary === 'function' ? boundary : (node: any) => node !== boundary\n\n if (!isElement(target)) {\n throw new TypeError('Invalid target')\n }\n\n // Used to handle the top most element that can be scrolled\n const scrollingElement = document.scrollingElement || document.documentElement\n\n // Collect all the scrolling boxes, as defined in the spec: https://drafts.csswg.org/cssom-view/#scrolling-box\n const frames: Element[] = []\n let cursor: Element | null = target\n while (isElement(cursor) && checkBoundary(cursor)) {\n // Move cursor to parent\n cursor = getParentElement(cursor)\n\n // Stop when we reach the viewport\n if (cursor === scrollingElement) {\n frames.push(cursor)\n break\n }\n\n // Skip document.body if it's not the scrollingElement and documentElement isn't independently scrollable\n if (\n cursor != null &&\n cursor === document.body &&\n isScrollable(cursor) &&\n !isScrollable(document.documentElement)\n ) {\n continue\n }\n\n // Now we check if the element is scrollable, this code only runs if the loop haven't already hit the viewport or a custom boundary\n if (cursor != null && isScrollable(cursor, skipOverflowHiddenElements)) {\n frames.push(cursor)\n }\n }\n\n // Support pinch-zooming properly, making sure elements scroll into the visual viewport\n // Browsers that don't support visualViewport will report the layout viewport dimensions on document.documentElement.clientWidth/Height\n // and viewport dimensions on window.innerWidth/Height\n // https://www.quirksmode.org/mobile/viewports2.html\n // https://bokand.github.io/viewport/index.html\n const viewportWidth = window.visualViewport?.width ?? innerWidth\n const viewportHeight = window.visualViewport?.height ?? innerHeight\n const { scrollX, scrollY } = window\n\n const {\n height: targetHeight,\n width: targetWidth,\n top: targetTop,\n right: targetRight,\n bottom: targetBottom,\n left: targetLeft,\n } = target.getBoundingClientRect()\n\n // These values mutate as we loop through and generate scroll coordinates\n let targetBlock: number =\n block === 'start' || block === 'nearest'\n ? targetTop\n : block === 'end'\n ? targetBottom\n : targetTop + targetHeight / 2 // block === 'center\n let targetInline: number =\n inline === 'center'\n ? targetLeft + targetWidth / 2\n : inline === 'end'\n ? targetRight\n : targetLeft // inline === 'start || inline === 'nearest\n\n // Collect new scroll positions\n const computations: ScrollAction[] = []\n // In chrome there's no longer a difference between caching the `frames.length` to a var or not, so we don't in this case (size > speed anyways)\n for (let index = 0; index < frames.length; index++) {\n const frame = frames[index]\n\n // @TODO add a shouldScroll hook here that allows userland code to take control\n\n const { height, width, top, right, bottom, left } =\n frame.getBoundingClientRect()\n\n // If the element is already visible we can end it here\n // @TODO targetBlock and targetInline should be taken into account to be compliant with https://github.com/w3c/csswg-drafts/pull/1805/files#diff-3c17f0e43c20f8ecf89419d49e7ef5e0R1333\n if (\n scrollMode === 'if-needed' &&\n targetTop >= 0 &&\n targetLeft >= 0 &&\n targetBottom <= viewportHeight &&\n targetRight <= viewportWidth &&\n targetTop >= top &&\n targetBottom <= bottom &&\n targetLeft >= left &&\n targetRight <= right\n ) {\n // Break the loop and return the computations for things that are not fully visible\n return computations\n }\n\n const frameStyle = getComputedStyle(frame)\n const borderLeft = parseInt(frameStyle.borderLeftWidth as string, 10)\n const borderTop = parseInt(frameStyle.borderTopWidth as string, 10)\n const borderRight = parseInt(frameStyle.borderRightWidth as string, 10)\n const borderBottom = parseInt(frameStyle.borderBottomWidth as string, 10)\n\n let blockScroll: number = 0\n let inlineScroll: number = 0\n\n // The property existance checks for offfset[Width|Height] is because only HTMLElement objects have them, but any Element might pass by here\n // @TODO find out if the \"as HTMLElement\" overrides can be dropped\n const scrollbarWidth =\n 'offsetWidth' in frame\n ? (frame as HTMLElement).offsetWidth -\n (frame as HTMLElement).clientWidth -\n borderLeft -\n borderRight\n : 0\n const scrollbarHeight =\n 'offsetHeight' in frame\n ? (frame as HTMLElement).offsetHeight -\n (frame as HTMLElement).clientHeight -\n borderTop -\n borderBottom\n : 0\n\n const scaleX =\n 'offsetWidth' in frame\n ? (frame as HTMLElement).offsetWidth === 0\n ? 0\n : width / (frame as HTMLElement).offsetWidth\n : 0\n const scaleY =\n 'offsetHeight' in frame\n ? (frame as HTMLElement).offsetHeight === 0\n ? 0\n : height / (frame as HTMLElement).offsetHeight\n : 0\n\n if (scrollingElement === frame) {\n // Handle viewport logic (document.documentElement or document.body)\n\n if (block === 'start') {\n blockScroll = targetBlock\n } else if (block === 'end') {\n blockScroll = targetBlock - viewportHeight\n } else if (block === 'nearest') {\n blockScroll = alignNearest(\n scrollY,\n scrollY + viewportHeight,\n viewportHeight,\n borderTop,\n borderBottom,\n scrollY + targetBlock,\n scrollY + targetBlock + targetHeight,\n targetHeight\n )\n } else {\n // block === 'center' is the default\n blockScroll = targetBlock - viewportHeight / 2\n }\n\n if (inline === 'start') {\n inlineScroll = targetInline\n } else if (inline === 'center') {\n inlineScroll = targetInline - viewportWidth / 2\n } else if (inline === 'end') {\n inlineScroll = targetInline - viewportWidth\n } else {\n // inline === 'nearest' is the default\n inlineScroll = alignNearest(\n scrollX,\n scrollX + viewportWidth,\n viewportWidth,\n borderLeft,\n borderRight,\n scrollX + targetInline,\n scrollX + targetInline + targetWidth,\n targetWidth\n )\n }\n\n // Apply scroll position offsets and ensure they are within bounds\n // @TODO add more test cases to cover this 100%\n blockScroll = Math.max(0, blockScroll + scrollY)\n inlineScroll = Math.max(0, inlineScroll + scrollX)\n } else {\n // Handle each scrolling frame that might exist between the target and the viewport\n if (block === 'start') {\n blockScroll = targetBlock - top - borderTop\n } else if (block === 'end') {\n blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight\n } else if (block === 'nearest') {\n blockScroll = alignNearest(\n top,\n bottom,\n height,\n borderTop,\n borderBottom + scrollbarHeight,\n targetBlock,\n targetBlock + targetHeight,\n targetHeight\n )\n } else {\n // block === 'center' is the default\n blockScroll = targetBlock - (top + height / 2) + scrollbarHeight / 2\n }\n\n if (inline === 'start') {\n inlineScroll = targetInline - left - borderLeft\n } else if (inline === 'center') {\n inlineScroll = targetInline - (left + width / 2) + scrollbarWidth / 2\n } else if (inline === 'end') {\n inlineScroll = targetInline - right + borderRight + scrollbarWidth\n } else {\n // inline === 'nearest' is the default\n inlineScroll = alignNearest(\n left,\n right,\n width,\n borderLeft,\n borderRight + scrollbarWidth,\n targetInline,\n targetInline + targetWidth,\n targetWidth\n )\n }\n\n const { scrollLeft, scrollTop } = frame\n // Ensure scroll coordinates are not out of bounds while applying scroll offsets\n blockScroll = Math.max(\n 0,\n Math.min(\n scrollTop + blockScroll / scaleY,\n frame.scrollHeight - height / scaleY + scrollbarHeight\n )\n )\n inlineScroll = Math.max(\n 0,\n Math.min(\n scrollLeft + inlineScroll / scaleX,\n frame.scrollWidth - width / scaleX + scrollbarWidth\n )\n )\n\n // Cache the offset so that parent frames can scroll this into view correctly\n targetBlock += scrollTop - blockScroll\n targetInline += scrollLeft - inlineScroll\n }\n\n computations.push({ el: frame, top: blockScroll, left: inlineScroll })\n }\n\n return computations\n}\n", "import { compute } from 'compute-scroll-into-view'\nimport type {\n Options as BaseOptions,\n ScrollAction,\n} from 'compute-scroll-into-view'\n\n/** @public */\nexport type Options =\n | StandardBehaviorOptions\n | CustomBehaviorOptions\n\n/**\n * Only scrolls if the `node` is partially out of view:\n * ```ts\n * scrollIntoView(node, { scrollMode: 'if-needed' })\n * ```\n * Skips scrolling `overflow: hidden` elements:\n * ```ts\n * scrollIntoView(node, { skipOverflowHiddenElements: true })\n * ```\n * When scrolling is needed do the least and smoothest scrolling possible:\n * ```ts\n * scrollIntoView(node, {\n * behavior: 'smooth',\n * scrollMode: 'if-needed',\n * block: 'nearest',\n * inline: 'nearest',\n * })\n * ```\n * @public\n */\nexport interface StandardBehaviorOptions extends BaseOptions {\n /**\n * @defaultValue 'auto\n */\n behavior?: ScrollBehavior\n}\n\n/** @public */\nexport interface CustomBehaviorOptions extends BaseOptions {\n behavior: CustomScrollBehaviorCallback\n}\n\n/** @public */\nexport type CustomScrollBehaviorCallback = (\n actions: ScrollAction[]\n) => T\n\nconst isStandardScrollBehavior = (\n options: any\n): options is StandardBehaviorOptions =>\n options === Object(options) && Object.keys(options).length !== 0\n\nconst isCustomScrollBehavior = (\n options: any\n): options is CustomBehaviorOptions =>\n typeof options === 'object' ? typeof options.behavior === 'function' : false\n\nconst getOptions = (options: any): StandardBehaviorOptions => {\n // Handle alignToTop for legacy reasons, to be compatible with the spec\n if (options === false) {\n return { block: 'end', inline: 'nearest' }\n }\n\n if (isStandardScrollBehavior(options)) {\n // compute.ts ensures the defaults are block: 'center' and inline: 'nearest', to conform to the spec\n return options\n }\n\n // if options = {}, options = true or options = null, based on w3c web platform test\n return { block: 'start', inline: 'nearest' }\n}\n\n// Determine if the element is part of the document (including shadow dom)\n// Derived from code of Andy Desmarais\n// https://terodox.tech/how-to-tell-if-an-element-is-in-the-dom-including-the-shadow-dom/\nconst isInDocument = (element: Node) => {\n let currentElement = element\n while (currentElement && currentElement.parentNode) {\n if (currentElement.parentNode === document) {\n return true\n } else if (currentElement.parentNode instanceof ShadowRoot) {\n currentElement = (currentElement.parentNode as ShadowRoot).host\n } else {\n currentElement = currentElement.parentNode\n }\n }\n return false\n}\n\n/**\n * Scrolls the given element into view, with options for when, and how.\n * Supports the same `options` as [`Element.prototype.scrollIntoView`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) with additions such as `scrollMode`, `behavior: Function` and `skipOverflowHiddenElements`.\n * @public\n */\nfunction scrollIntoView(\n target: Element,\n options?: StandardBehaviorOptions | boolean\n): void\n/**\n * Scrolls the given element into view, with options for when, and how.\n * Supports the same `options` as [`Element.prototype.scrollIntoView`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) with additions such as `scrollMode`, `behavior: Function` and `skipOverflowHiddenElements`.\n *\n * You can set the expected return type for `behavior: Function`:\n * ```ts\n * await scrollIntoView>(node, {\n * behavior: async actions => {\n * return Promise.all(actions.map(\n * // animate() resolves to `true` if anything was animated, `false` if the element already were in the end state\n * ({ el, left, top }) => animate(el, {scroll: {left, top}})\n * ))\n * }\n * })\n * ```\n * @public\n */\nfunction scrollIntoView(\n target: Element,\n options: CustomBehaviorOptions\n): T\nfunction scrollIntoView(\n target: Element,\n options?: StandardBehaviorOptions | CustomBehaviorOptions | boolean\n): T | void {\n // Browsers treats targets that aren't in the dom as a no-op and so should we\n if (!target.isConnected || !isInDocument(target)) {\n return\n }\n\n if (isCustomScrollBehavior(options)) {\n return options.behavior(compute(target, options))\n }\n\n const behavior = typeof options === 'boolean' ? undefined : options?.behavior\n\n for (const { el, top, left } of compute(target, getOptions(options))) {\n el.scroll({ top, left, behavior })\n }\n}\n\nexport default scrollIntoView\n", "export var top = 'top';\nexport var bottom = 'bottom';\nexport var right = 'right';\nexport var left = 'left';\nexport var auto = 'auto';\nexport var basePlacements = [top, bottom, right, left];\nexport var start = 'start';\nexport var end = 'end';\nexport var clippingParents = 'clippingParents';\nexport var viewport = 'viewport';\nexport var popper = 'popper';\nexport var reference = 'reference';\nexport var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {\n return acc.concat([placement + \"-\" + start, placement + \"-\" + end]);\n}, []);\nexport var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {\n return acc.concat([placement, placement + \"-\" + start, placement + \"-\" + end]);\n}, []); // modifiers that need to read the DOM\n\nexport var beforeRead = 'beforeRead';\nexport var read = 'read';\nexport var afterRead = 'afterRead'; // pure-logic modifiers\n\nexport var beforeMain = 'beforeMain';\nexport var main = 'main';\nexport var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)\n\nexport var beforeWrite = 'beforeWrite';\nexport var write = 'write';\nexport var afterWrite = 'afterWrite';\nexport var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];", "export default function getNodeName(element) {\n return element ? (element.nodeName || '').toLowerCase() : null;\n}", "export default function getWindow(node) {\n if (node == null) {\n return window;\n }\n\n if (node.toString() !== '[object Window]') {\n var ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}", "import getWindow from \"./getWindow.js\";\n\nfunction isElement(node) {\n var OwnElement = getWindow(node).Element;\n return node instanceof OwnElement || node instanceof Element;\n}\n\nfunction isHTMLElement(node) {\n var OwnElement = getWindow(node).HTMLElement;\n return node instanceof OwnElement || node instanceof HTMLElement;\n}\n\nfunction isShadowRoot(node) {\n // IE 11 has no ShadowRoot\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n var OwnElement = getWindow(node).ShadowRoot;\n return node instanceof OwnElement || node instanceof ShadowRoot;\n}\n\nexport { isElement, isHTMLElement, isShadowRoot };", "import getNodeName from \"../dom-utils/getNodeName.js\";\nimport { isHTMLElement } from \"../dom-utils/instanceOf.js\"; // This modifier takes the styles prepared by the `computeStyles` modifier\n// and applies them to the HTMLElements such as popper and arrow\n\nfunction applyStyles(_ref) {\n var state = _ref.state;\n Object.keys(state.elements).forEach(function (name) {\n var style = state.styles[name] || {};\n var attributes = state.attributes[name] || {};\n var element = state.elements[name]; // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n } // Flow doesn't support to extend this property, but it's the most\n // effective way to apply styles to an HTMLElement\n // $FlowFixMe[cannot-write]\n\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (name) {\n var value = attributes[name];\n\n if (value === false) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value === true ? '' : value);\n }\n });\n });\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state;\n var initialStyles = {\n popper: {\n position: state.options.strategy,\n left: '0',\n top: '0',\n margin: '0'\n },\n arrow: {\n position: 'absolute'\n },\n reference: {}\n };\n Object.assign(state.elements.popper.style, initialStyles.popper);\n state.styles = initialStyles;\n\n if (state.elements.arrow) {\n Object.assign(state.elements.arrow.style, initialStyles.arrow);\n }\n\n return function () {\n Object.keys(state.elements).forEach(function (name) {\n var element = state.elements[name];\n var attributes = state.attributes[name] || {};\n var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them\n\n var style = styleProperties.reduce(function (style, property) {\n style[property] = '';\n return style;\n }, {}); // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n }\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (attribute) {\n element.removeAttribute(attribute);\n });\n });\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'applyStyles',\n enabled: true,\n phase: 'write',\n fn: applyStyles,\n effect: effect,\n requires: ['computeStyles']\n};", "import { auto } from \"../enums.js\";\nexport default function getBasePlacement(placement) {\n return placement.split('-')[0];\n}", "export var max = Math.max;\nexport var min = Math.min;\nexport var round = Math.round;", "export default function getUAString() {\n var uaData = navigator.userAgentData;\n\n if (uaData != null && uaData.brands) {\n return uaData.brands.map(function (item) {\n return item.brand + \"/\" + item.version;\n }).join(' ');\n }\n\n return navigator.userAgent;\n}", "import getUAString from \"../utils/userAgent.js\";\nexport default function isLayoutViewport() {\n return !/^((?!chrome|android).)*safari/i.test(getUAString());\n}", "import { isElement, isHTMLElement } from \"./instanceOf.js\";\nimport { round } from \"../utils/math.js\";\nimport getWindow from \"./getWindow.js\";\nimport isLayoutViewport from \"./isLayoutViewport.js\";\nexport default function getBoundingClientRect(element, includeScale, isFixedStrategy) {\n if (includeScale === void 0) {\n includeScale = false;\n }\n\n if (isFixedStrategy === void 0) {\n isFixedStrategy = false;\n }\n\n var clientRect = element.getBoundingClientRect();\n var scaleX = 1;\n var scaleY = 1;\n\n if (includeScale && isHTMLElement(element)) {\n scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;\n scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;\n }\n\n var _ref = isElement(element) ? getWindow(element) : window,\n visualViewport = _ref.visualViewport;\n\n var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;\n var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;\n var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;\n var width = clientRect.width / scaleX;\n var height = clientRect.height / scaleY;\n return {\n width: width,\n height: height,\n top: y,\n right: x + width,\n bottom: y + height,\n left: x,\n x: x,\n y: y\n };\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\"; // Returns the layout rect of an element relative to its offsetParent. Layout\n// means it doesn't take into account transforms.\n\nexport default function getLayoutRect(element) {\n var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.\n // Fixes https://github.com/popperjs/popper-core/issues/1223\n\n var width = element.offsetWidth;\n var height = element.offsetHeight;\n\n if (Math.abs(clientRect.width - width) <= 1) {\n width = clientRect.width;\n }\n\n if (Math.abs(clientRect.height - height) <= 1) {\n height = clientRect.height;\n }\n\n return {\n x: element.offsetLeft,\n y: element.offsetTop,\n width: width,\n height: height\n };\n}", "import { isShadowRoot } from \"./instanceOf.js\";\nexport default function contains(parent, child) {\n var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method\n\n if (parent.contains(child)) {\n return true;\n } // then fallback to custom implementation with Shadow DOM support\n else if (rootNode && isShadowRoot(rootNode)) {\n var next = child;\n\n do {\n if (next && parent.isSameNode(next)) {\n return true;\n } // $FlowFixMe[prop-missing]: need a better way to handle this...\n\n\n next = next.parentNode || next.host;\n } while (next);\n } // Give up, the result is false\n\n\n return false;\n}", "import getWindow from \"./getWindow.js\";\nexport default function getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}", "import getNodeName from \"./getNodeName.js\";\nexport default function isTableElement(element) {\n return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;\n}", "import { isElement } from \"./instanceOf.js\";\nexport default function getDocumentElement(element) {\n // $FlowFixMe[incompatible-return]: assume body is always available\n return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]\n element.document) || window.document).documentElement;\n}", "import getNodeName from \"./getNodeName.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport { isShadowRoot } from \"./instanceOf.js\";\nexport default function getParentNode(element) {\n if (getNodeName(element) === 'html') {\n return element;\n }\n\n return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // $FlowFixMe[incompatible-return]\n // $FlowFixMe[prop-missing]\n element.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n element.parentNode || ( // DOM Element detected\n isShadowRoot(element) ? element.host : null) || // ShadowRoot detected\n // $FlowFixMe[incompatible-call]: HTMLElement is a Node\n getDocumentElement(element) // fallback\n\n );\n}", "import getWindow from \"./getWindow.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isHTMLElement, isShadowRoot } from \"./instanceOf.js\";\nimport isTableElement from \"./isTableElement.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getUAString from \"../utils/userAgent.js\";\n\nfunction getTrueOffsetParent(element) {\n if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837\n getComputedStyle(element).position === 'fixed') {\n return null;\n }\n\n return element.offsetParent;\n} // `.offsetParent` reports `null` for fixed elements, while absolute elements\n// return the containing block\n\n\nfunction getContainingBlock(element) {\n var isFirefox = /firefox/i.test(getUAString());\n var isIE = /Trident/i.test(getUAString());\n\n if (isIE && isHTMLElement(element)) {\n // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport\n var elementCss = getComputedStyle(element);\n\n if (elementCss.position === 'fixed') {\n return null;\n }\n }\n\n var currentNode = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {\n var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {\n return currentNode;\n } else {\n currentNode = currentNode.parentNode;\n }\n }\n\n return null;\n} // Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\n\n\nexport default function getOffsetParent(element) {\n var window = getWindow(element);\n var offsetParent = getTrueOffsetParent(element);\n\n while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {\n offsetParent = getTrueOffsetParent(offsetParent);\n }\n\n if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {\n return window;\n }\n\n return offsetParent || getContainingBlock(element) || window;\n}", "export default function getMainAxisFromPlacement(placement) {\n return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';\n}", "import { max as mathMax, min as mathMin } from \"./math.js\";\nexport function within(min, value, max) {\n return mathMax(min, mathMin(value, max));\n}\nexport function withinMaxClamp(min, value, max) {\n var v = within(min, value, max);\n return v > max ? max : v;\n}", "export default function getFreshSideObject() {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n };\n}", "import getFreshSideObject from \"./getFreshSideObject.js\";\nexport default function mergePaddingObject(paddingObject) {\n return Object.assign({}, getFreshSideObject(), paddingObject);\n}", "export default function expandToHashMap(value, keys) {\n return keys.reduce(function (hashMap, key) {\n hashMap[key] = value;\n return hashMap;\n }, {});\n}", "import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport contains from \"../dom-utils/contains.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport { within } from \"../utils/within.js\";\nimport mergePaddingObject from \"../utils/mergePaddingObject.js\";\nimport expandToHashMap from \"../utils/expandToHashMap.js\";\nimport { left, right, basePlacements, top, bottom } from \"../enums.js\";\nimport { isHTMLElement } from \"../dom-utils/instanceOf.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar toPaddingObject = function toPaddingObject(padding, state) {\n padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {\n placement: state.placement\n })) : padding;\n return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));\n};\n\nfunction arrow(_ref) {\n var _state$modifiersData$;\n\n var state = _ref.state,\n name = _ref.name,\n options = _ref.options;\n var arrowElement = state.elements.arrow;\n var popperOffsets = state.modifiersData.popperOffsets;\n var basePlacement = getBasePlacement(state.placement);\n var axis = getMainAxisFromPlacement(basePlacement);\n var isVertical = [left, right].indexOf(basePlacement) >= 0;\n var len = isVertical ? 'height' : 'width';\n\n if (!arrowElement || !popperOffsets) {\n return;\n }\n\n var paddingObject = toPaddingObject(options.padding, state);\n var arrowRect = getLayoutRect(arrowElement);\n var minProp = axis === 'y' ? top : left;\n var maxProp = axis === 'y' ? bottom : right;\n var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];\n var startDiff = popperOffsets[axis] - state.rects.reference[axis];\n var arrowOffsetParent = getOffsetParent(arrowElement);\n var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;\n var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is\n // outside of the popper bounds\n\n var min = paddingObject[minProp];\n var max = clientSize - arrowRect[len] - paddingObject[maxProp];\n var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;\n var offset = within(min, center, max); // Prevents breaking syntax highlighting...\n\n var axisProp = axis;\n state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state,\n options = _ref2.options;\n var _options$element = options.element,\n arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;\n\n if (arrowElement == null) {\n return;\n } // CSS selector\n\n\n if (typeof arrowElement === 'string') {\n arrowElement = state.elements.popper.querySelector(arrowElement);\n\n if (!arrowElement) {\n return;\n }\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!isHTMLElement(arrowElement)) {\n console.error(['Popper: \"arrow\" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));\n }\n }\n\n if (!contains(state.elements.popper, arrowElement)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(['Popper: \"arrow\" modifier\\'s `element` must be a child of the popper', 'element.'].join(' '));\n }\n\n return;\n }\n\n state.elements.arrow = arrowElement;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'arrow',\n enabled: true,\n phase: 'main',\n fn: arrow,\n effect: effect,\n requires: ['popperOffsets'],\n requiresIfExists: ['preventOverflow']\n};", "export default function getVariation(placement) {\n return placement.split('-')[1];\n}", "import { top, left, right, bottom, end } from \"../enums.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getWindow from \"../dom-utils/getWindow.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport getComputedStyle from \"../dom-utils/getComputedStyle.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getVariation from \"../utils/getVariation.js\";\nimport { round } from \"../utils/math.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar unsetSides = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto'\n}; // Round the offsets to the nearest suitable subpixel based on the DPR.\n// Zooming can change the DPR, but it seems to report a value that will\n// cleanly divide the values into the appropriate subpixels.\n\nfunction roundOffsetsByDPR(_ref) {\n var x = _ref.x,\n y = _ref.y;\n var win = window;\n var dpr = win.devicePixelRatio || 1;\n return {\n x: round(x * dpr) / dpr || 0,\n y: round(y * dpr) / dpr || 0\n };\n}\n\nexport function mapToStyles(_ref2) {\n var _Object$assign2;\n\n var popper = _ref2.popper,\n popperRect = _ref2.popperRect,\n placement = _ref2.placement,\n variation = _ref2.variation,\n offsets = _ref2.offsets,\n position = _ref2.position,\n gpuAcceleration = _ref2.gpuAcceleration,\n adaptive = _ref2.adaptive,\n roundOffsets = _ref2.roundOffsets,\n isFixed = _ref2.isFixed;\n var _offsets$x = offsets.x,\n x = _offsets$x === void 0 ? 0 : _offsets$x,\n _offsets$y = offsets.y,\n y = _offsets$y === void 0 ? 0 : _offsets$y;\n\n var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({\n x: x,\n y: y\n }) : {\n x: x,\n y: y\n };\n\n x = _ref3.x;\n y = _ref3.y;\n var hasX = offsets.hasOwnProperty('x');\n var hasY = offsets.hasOwnProperty('y');\n var sideX = left;\n var sideY = top;\n var win = window;\n\n if (adaptive) {\n var offsetParent = getOffsetParent(popper);\n var heightProp = 'clientHeight';\n var widthProp = 'clientWidth';\n\n if (offsetParent === getWindow(popper)) {\n offsetParent = getDocumentElement(popper);\n\n if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {\n heightProp = 'scrollHeight';\n widthProp = 'scrollWidth';\n }\n } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it\n\n\n offsetParent = offsetParent;\n\n if (placement === top || (placement === left || placement === right) && variation === end) {\n sideY = bottom;\n var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]\n offsetParent[heightProp];\n y -= offsetY - popperRect.height;\n y *= gpuAcceleration ? 1 : -1;\n }\n\n if (placement === left || (placement === top || placement === bottom) && variation === end) {\n sideX = right;\n var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]\n offsetParent[widthProp];\n x -= offsetX - popperRect.width;\n x *= gpuAcceleration ? 1 : -1;\n }\n }\n\n var commonStyles = Object.assign({\n position: position\n }, adaptive && unsetSides);\n\n var _ref4 = roundOffsets === true ? roundOffsetsByDPR({\n x: x,\n y: y\n }) : {\n x: x,\n y: y\n };\n\n x = _ref4.x;\n y = _ref4.y;\n\n if (gpuAcceleration) {\n var _Object$assign;\n\n return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? \"translate(\" + x + \"px, \" + y + \"px)\" : \"translate3d(\" + x + \"px, \" + y + \"px, 0)\", _Object$assign));\n }\n\n return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + \"px\" : '', _Object$assign2[sideX] = hasX ? x + \"px\" : '', _Object$assign2.transform = '', _Object$assign2));\n}\n\nfunction computeStyles(_ref5) {\n var state = _ref5.state,\n options = _ref5.options;\n var _options$gpuAccelerat = options.gpuAcceleration,\n gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,\n _options$adaptive = options.adaptive,\n adaptive = _options$adaptive === void 0 ? true : _options$adaptive,\n _options$roundOffsets = options.roundOffsets,\n roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;\n\n if (process.env.NODE_ENV !== \"production\") {\n var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';\n\n if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {\n return transitionProperty.indexOf(property) >= 0;\n })) {\n console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: \"transform\", \"top\", \"right\", \"bottom\", \"left\".', '\\n\\n', 'Disable the \"computeStyles\" modifier\\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\\n\\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));\n }\n }\n\n var commonStyles = {\n placement: getBasePlacement(state.placement),\n variation: getVariation(state.placement),\n popper: state.elements.popper,\n popperRect: state.rects.popper,\n gpuAcceleration: gpuAcceleration,\n isFixed: state.options.strategy === 'fixed'\n };\n\n if (state.modifiersData.popperOffsets != null) {\n state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {\n offsets: state.modifiersData.popperOffsets,\n position: state.options.strategy,\n adaptive: adaptive,\n roundOffsets: roundOffsets\n })));\n }\n\n if (state.modifiersData.arrow != null) {\n state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {\n offsets: state.modifiersData.arrow,\n position: 'absolute',\n adaptive: false,\n roundOffsets: roundOffsets\n })));\n }\n\n state.attributes.popper = Object.assign({}, state.attributes.popper, {\n 'data-popper-placement': state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'computeStyles',\n enabled: true,\n phase: 'beforeWrite',\n fn: computeStyles,\n data: {}\n};", "import getWindow from \"../dom-utils/getWindow.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar passive = {\n passive: true\n};\n\nfunction effect(_ref) {\n var state = _ref.state,\n instance = _ref.instance,\n options = _ref.options;\n var _options$scroll = options.scroll,\n scroll = _options$scroll === void 0 ? true : _options$scroll,\n _options$resize = options.resize,\n resize = _options$resize === void 0 ? true : _options$resize;\n var window = getWindow(state.elements.popper);\n var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);\n\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.addEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.addEventListener('resize', instance.update, passive);\n }\n\n return function () {\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.removeEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.removeEventListener('resize', instance.update, passive);\n }\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'eventListeners',\n enabled: true,\n phase: 'write',\n fn: function fn() {},\n effect: effect,\n data: {}\n};", "var hash = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nexport default function getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, function (matched) {\n return hash[matched];\n });\n}", "var hash = {\n start: 'end',\n end: 'start'\n};\nexport default function getOppositeVariationPlacement(placement) {\n return placement.replace(/start|end/g, function (matched) {\n return hash[matched];\n });\n}", "import getWindow from \"./getWindow.js\";\nexport default function getWindowScroll(node) {\n var win = getWindow(node);\n var scrollLeft = win.pageXOffset;\n var scrollTop = win.pageYOffset;\n return {\n scrollLeft: scrollLeft,\n scrollTop: scrollTop\n };\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScroll from \"./getWindowScroll.js\";\nexport default function getWindowScrollBarX(element) {\n // If has a CSS width greater than the viewport, then this will be\n // incorrect for RTL.\n // Popper 1 is broken in this case and never had a bug report so let's assume\n // it's not an issue. I don't think anyone ever specifies width on \n // anyway.\n // Browsers where the left scrollbar doesn't cause an issue report `0` for\n // this (e.g. Edge 2019, IE11, Safari)\n return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;\n}", "import getWindow from \"./getWindow.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport isLayoutViewport from \"./isLayoutViewport.js\";\nexport default function getViewportRect(element, strategy) {\n var win = getWindow(element);\n var html = getDocumentElement(element);\n var visualViewport = win.visualViewport;\n var width = html.clientWidth;\n var height = html.clientHeight;\n var x = 0;\n var y = 0;\n\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height;\n var layoutViewport = isLayoutViewport();\n\n if (layoutViewport || !layoutViewport && strategy === 'fixed') {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n\n return {\n width: width,\n height: height,\n x: x + getWindowScrollBarX(element),\n y: y\n };\n}", "import getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getWindowScroll from \"./getWindowScroll.js\";\nimport { max } from \"../utils/math.js\"; // Gets the entire size of the scrollable document area, even extending outside\n// of the `` and `` rect bounds if horizontally scrollable\n\nexport default function getDocumentRect(element) {\n var _element$ownerDocumen;\n\n var html = getDocumentElement(element);\n var winScroll = getWindowScroll(element);\n var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;\n var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);\n var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);\n var x = -winScroll.scrollLeft + getWindowScrollBarX(element);\n var y = -winScroll.scrollTop;\n\n if (getComputedStyle(body || html).direction === 'rtl') {\n x += max(html.clientWidth, body ? body.clientWidth : 0) - width;\n }\n\n return {\n width: width,\n height: height,\n x: x,\n y: y\n };\n}", "import getComputedStyle from \"./getComputedStyle.js\";\nexport default function isScrollParent(element) {\n // Firefox wants us to check `-x` and `-y` variations as well\n var _getComputedStyle = getComputedStyle(element),\n overflow = _getComputedStyle.overflow,\n overflowX = _getComputedStyle.overflowX,\n overflowY = _getComputedStyle.overflowY;\n\n return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);\n}", "import getParentNode from \"./getParentNode.js\";\nimport isScrollParent from \"./isScrollParent.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nexport default function getScrollParent(node) {\n if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {\n // $FlowFixMe[incompatible-return]: assume body is always available\n return node.ownerDocument.body;\n }\n\n if (isHTMLElement(node) && isScrollParent(node)) {\n return node;\n }\n\n return getScrollParent(getParentNode(node));\n}", "import getScrollParent from \"./getScrollParent.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getWindow from \"./getWindow.js\";\nimport isScrollParent from \"./isScrollParent.js\";\n/*\ngiven a DOM element, return the list of all scroll parents, up the list of ancesors\nuntil we get to the top window object. This list is what we attach scroll listeners\nto, because if any of these parent elements scroll, we'll need to re-calculate the\nreference element's position.\n*/\n\nexport default function listScrollParents(element, list) {\n var _element$ownerDocumen;\n\n if (list === void 0) {\n list = [];\n }\n\n var scrollParent = getScrollParent(element);\n var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);\n var win = getWindow(scrollParent);\n var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;\n var updatedList = list.concat(target);\n return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here\n updatedList.concat(listScrollParents(getParentNode(target)));\n}", "export default function rectToClientRect(rect) {\n return Object.assign({}, rect, {\n left: rect.x,\n top: rect.y,\n right: rect.x + rect.width,\n bottom: rect.y + rect.height\n });\n}", "import { viewport } from \"../enums.js\";\nimport getViewportRect from \"./getViewportRect.js\";\nimport getDocumentRect from \"./getDocumentRect.js\";\nimport listScrollParents from \"./listScrollParents.js\";\nimport getOffsetParent from \"./getOffsetParent.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isElement, isHTMLElement } from \"./instanceOf.js\";\nimport getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport contains from \"./contains.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport rectToClientRect from \"../utils/rectToClientRect.js\";\nimport { max, min } from \"../utils/math.js\";\n\nfunction getInnerBoundingClientRect(element, strategy) {\n var rect = getBoundingClientRect(element, false, strategy === 'fixed');\n rect.top = rect.top + element.clientTop;\n rect.left = rect.left + element.clientLeft;\n rect.bottom = rect.top + element.clientHeight;\n rect.right = rect.left + element.clientWidth;\n rect.width = element.clientWidth;\n rect.height = element.clientHeight;\n rect.x = rect.left;\n rect.y = rect.top;\n return rect;\n}\n\nfunction getClientRectFromMixedType(element, clippingParent, strategy) {\n return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));\n} // A \"clipping parent\" is an overflowable container with the characteristic of\n// clipping (or hiding) overflowing elements with a position different from\n// `initial`\n\n\nfunction getClippingParents(element) {\n var clippingParents = listScrollParents(getParentNode(element));\n var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;\n var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;\n\n if (!isElement(clipperElement)) {\n return [];\n } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414\n\n\n return clippingParents.filter(function (clippingParent) {\n return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';\n });\n} // Gets the maximum area that the element is visible in due to any number of\n// clipping parents\n\n\nexport default function getClippingRect(element, boundary, rootBoundary, strategy) {\n var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);\n var clippingParents = [].concat(mainClippingParents, [rootBoundary]);\n var firstClippingParent = clippingParents[0];\n var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {\n var rect = getClientRectFromMixedType(element, clippingParent, 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 }, getClientRectFromMixedType(element, firstClippingParent, strategy));\n clippingRect.width = clippingRect.right - clippingRect.left;\n clippingRect.height = clippingRect.bottom - clippingRect.top;\n clippingRect.x = clippingRect.left;\n clippingRect.y = clippingRect.top;\n return clippingRect;\n}", "import getBasePlacement from \"./getBasePlacement.js\";\nimport getVariation from \"./getVariation.js\";\nimport getMainAxisFromPlacement from \"./getMainAxisFromPlacement.js\";\nimport { top, right, bottom, left, start, end } from \"../enums.js\";\nexport default function computeOffsets(_ref) {\n var reference = _ref.reference,\n element = _ref.element,\n placement = _ref.placement;\n var basePlacement = placement ? getBasePlacement(placement) : null;\n var variation = placement ? getVariation(placement) : null;\n var commonX = reference.x + reference.width / 2 - element.width / 2;\n var commonY = reference.y + reference.height / 2 - element.height / 2;\n var offsets;\n\n switch (basePlacement) {\n case top:\n offsets = {\n x: commonX,\n y: reference.y - element.height\n };\n break;\n\n case bottom:\n offsets = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n\n case right:\n offsets = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n\n case left:\n offsets = {\n x: reference.x - element.width,\n y: commonY\n };\n break;\n\n default:\n offsets = {\n x: reference.x,\n y: reference.y\n };\n }\n\n var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;\n\n if (mainAxis != null) {\n var len = mainAxis === 'y' ? 'height' : 'width';\n\n switch (variation) {\n case start:\n offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);\n break;\n\n case end:\n offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);\n break;\n\n default:\n }\n }\n\n return offsets;\n}", "import getClippingRect from \"../dom-utils/getClippingRect.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport getBoundingClientRect from \"../dom-utils/getBoundingClientRect.js\";\nimport computeOffsets from \"./computeOffsets.js\";\nimport rectToClientRect from \"./rectToClientRect.js\";\nimport { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from \"../enums.js\";\nimport { isElement } from \"../dom-utils/instanceOf.js\";\nimport mergePaddingObject from \"./mergePaddingObject.js\";\nimport expandToHashMap from \"./expandToHashMap.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport default function detectOverflow(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n _options$placement = _options.placement,\n placement = _options$placement === void 0 ? state.placement : _options$placement,\n _options$strategy = _options.strategy,\n strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,\n _options$boundary = _options.boundary,\n boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,\n _options$rootBoundary = _options.rootBoundary,\n rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,\n _options$elementConte = _options.elementContext,\n elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,\n _options$altBoundary = _options.altBoundary,\n altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,\n _options$padding = _options.padding,\n padding = _options$padding === void 0 ? 0 : _options$padding;\n var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));\n var altContext = elementContext === popper ? reference : popper;\n var popperRect = state.rects.popper;\n var element = state.elements[altBoundary ? altContext : elementContext];\n var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);\n var referenceClientRect = getBoundingClientRect(state.elements.reference);\n var popperOffsets = computeOffsets({\n reference: referenceClientRect,\n element: popperRect,\n strategy: 'absolute',\n placement: placement\n });\n var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));\n var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect\n // 0 or negative = within the clipping rect\n\n var overflowOffsets = {\n top: clippingClientRect.top - elementClientRect.top + paddingObject.top,\n bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,\n left: clippingClientRect.left - elementClientRect.left + paddingObject.left,\n right: elementClientRect.right - clippingClientRect.right + paddingObject.right\n };\n var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element\n\n if (elementContext === popper && offsetData) {\n var offset = offsetData[placement];\n Object.keys(overflowOffsets).forEach(function (key) {\n var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;\n var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';\n overflowOffsets[key] += offset[axis] * multiply;\n });\n }\n\n return overflowOffsets;\n}", "import getVariation from \"./getVariation.js\";\nimport { variationPlacements, basePlacements, placements as allPlacements } from \"../enums.js\";\nimport detectOverflow from \"./detectOverflow.js\";\nimport getBasePlacement from \"./getBasePlacement.js\";\nexport default function computeAutoPlacement(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n placement = _options.placement,\n boundary = _options.boundary,\n rootBoundary = _options.rootBoundary,\n padding = _options.padding,\n flipVariations = _options.flipVariations,\n _options$allowedAutoP = _options.allowedAutoPlacements,\n allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;\n var variation = getVariation(placement);\n var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {\n return getVariation(placement) === variation;\n }) : basePlacements;\n var allowedPlacements = placements.filter(function (placement) {\n return allowedAutoPlacements.indexOf(placement) >= 0;\n });\n\n if (allowedPlacements.length === 0) {\n allowedPlacements = placements;\n\n if (process.env.NODE_ENV !== \"production\") {\n console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, \"auto\" cannot be used to allow \"bottom-start\".', 'Use \"auto-start\" instead.'].join(' '));\n }\n } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...\n\n\n var overflows = allowedPlacements.reduce(function (acc, placement) {\n acc[placement] = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding\n })[getBasePlacement(placement)];\n return acc;\n }, {});\n return Object.keys(overflows).sort(function (a, b) {\n return overflows[a] - overflows[b];\n });\n}", "import getOppositePlacement from \"../utils/getOppositePlacement.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getOppositeVariationPlacement from \"../utils/getOppositeVariationPlacement.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport computeAutoPlacement from \"../utils/computeAutoPlacement.js\";\nimport { bottom, top, start, right, left, auto } from \"../enums.js\";\nimport getVariation from \"../utils/getVariation.js\"; // eslint-disable-next-line import/no-unused-modules\n\nfunction getExpandedFallbackPlacements(placement) {\n if (getBasePlacement(placement) === auto) {\n return [];\n }\n\n var oppositePlacement = getOppositePlacement(placement);\n return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];\n}\n\nfunction flip(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n\n if (state.modifiersData[name]._skip) {\n return;\n }\n\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,\n specifiedFallbackPlacements = options.fallbackPlacements,\n padding = options.padding,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n _options$flipVariatio = options.flipVariations,\n flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,\n allowedAutoPlacements = options.allowedAutoPlacements;\n var preferredPlacement = state.options.placement;\n var basePlacement = getBasePlacement(preferredPlacement);\n var isBasePlacement = basePlacement === preferredPlacement;\n var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));\n var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {\n return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n flipVariations: flipVariations,\n allowedAutoPlacements: allowedAutoPlacements\n }) : placement);\n }, []);\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var checksMap = new Map();\n var makeFallbackChecks = true;\n var firstFittingPlacement = placements[0];\n\n for (var i = 0; i < placements.length; i++) {\n var placement = placements[i];\n\n var _basePlacement = getBasePlacement(placement);\n\n var isStartVariation = getVariation(placement) === start;\n var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;\n var len = isVertical ? 'width' : 'height';\n var overflow = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n altBoundary: altBoundary,\n padding: padding\n });\n var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;\n\n if (referenceRect[len] > popperRect[len]) {\n mainVariationSide = getOppositePlacement(mainVariationSide);\n }\n\n var altVariationSide = getOppositePlacement(mainVariationSide);\n var checks = [];\n\n if (checkMainAxis) {\n checks.push(overflow[_basePlacement] <= 0);\n }\n\n if (checkAltAxis) {\n checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);\n }\n\n if (checks.every(function (check) {\n return check;\n })) {\n firstFittingPlacement = placement;\n makeFallbackChecks = false;\n break;\n }\n\n checksMap.set(placement, checks);\n }\n\n if (makeFallbackChecks) {\n // `2` may be desired in some cases \u2013 research later\n var numberOfChecks = flipVariations ? 3 : 1;\n\n var _loop = function _loop(_i) {\n var fittingPlacement = placements.find(function (placement) {\n var checks = checksMap.get(placement);\n\n if (checks) {\n return checks.slice(0, _i).every(function (check) {\n return check;\n });\n }\n });\n\n if (fittingPlacement) {\n firstFittingPlacement = fittingPlacement;\n return \"break\";\n }\n };\n\n for (var _i = numberOfChecks; _i > 0; _i--) {\n var _ret = _loop(_i);\n\n if (_ret === \"break\") break;\n }\n }\n\n if (state.placement !== firstFittingPlacement) {\n state.modifiersData[name]._skip = true;\n state.placement = firstFittingPlacement;\n state.reset = true;\n }\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'flip',\n enabled: true,\n phase: 'main',\n fn: flip,\n requiresIfExists: ['offset'],\n data: {\n _skip: false\n }\n};", "import { top, bottom, left, right } from \"../enums.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\n\nfunction getSideOffsets(overflow, rect, preventedOffsets) {\n if (preventedOffsets === void 0) {\n preventedOffsets = {\n x: 0,\n y: 0\n };\n }\n\n return {\n top: overflow.top - rect.height - preventedOffsets.y,\n right: overflow.right - rect.width + preventedOffsets.x,\n bottom: overflow.bottom - rect.height + preventedOffsets.y,\n left: overflow.left - rect.width - preventedOffsets.x\n };\n}\n\nfunction isAnySideFullyClipped(overflow) {\n return [top, right, bottom, left].some(function (side) {\n return overflow[side] >= 0;\n });\n}\n\nfunction hide(_ref) {\n var state = _ref.state,\n name = _ref.name;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var preventedOffsets = state.modifiersData.preventOverflow;\n var referenceOverflow = detectOverflow(state, {\n elementContext: 'reference'\n });\n var popperAltOverflow = detectOverflow(state, {\n altBoundary: true\n });\n var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);\n var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);\n var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);\n var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);\n state.modifiersData[name] = {\n referenceClippingOffsets: referenceClippingOffsets,\n popperEscapeOffsets: popperEscapeOffsets,\n isReferenceHidden: isReferenceHidden,\n hasPopperEscaped: hasPopperEscaped\n };\n state.attributes.popper = Object.assign({}, state.attributes.popper, {\n 'data-popper-reference-hidden': isReferenceHidden,\n 'data-popper-escaped': hasPopperEscaped\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'hide',\n enabled: true,\n phase: 'main',\n requiresIfExists: ['preventOverflow'],\n fn: hide\n};", "import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport { top, left, right, placements } from \"../enums.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport function distanceAndSkiddingToXY(placement, rects, offset) {\n var basePlacement = getBasePlacement(placement);\n var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;\n\n var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {\n placement: placement\n })) : offset,\n skidding = _ref[0],\n distance = _ref[1];\n\n skidding = skidding || 0;\n distance = (distance || 0) * invertDistance;\n return [left, right].indexOf(basePlacement) >= 0 ? {\n x: distance,\n y: skidding\n } : {\n x: skidding,\n y: distance\n };\n}\n\nfunction offset(_ref2) {\n var state = _ref2.state,\n options = _ref2.options,\n name = _ref2.name;\n var _options$offset = options.offset,\n offset = _options$offset === void 0 ? [0, 0] : _options$offset;\n var data = placements.reduce(function (acc, placement) {\n acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);\n return acc;\n }, {});\n var _data$state$placement = data[state.placement],\n x = _data$state$placement.x,\n y = _data$state$placement.y;\n\n if (state.modifiersData.popperOffsets != null) {\n state.modifiersData.popperOffsets.x += x;\n state.modifiersData.popperOffsets.y += y;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'offset',\n enabled: true,\n phase: 'main',\n requires: ['popperOffsets'],\n fn: offset\n};", "import computeOffsets from \"../utils/computeOffsets.js\";\n\nfunction popperOffsets(_ref) {\n var state = _ref.state,\n name = _ref.name;\n // Offsets are the actual position the popper needs to have to be\n // properly positioned near its reference element\n // This is the most basic placement, and will be adjusted by\n // the modifiers in the next step\n state.modifiersData[name] = computeOffsets({\n reference: state.rects.reference,\n element: state.rects.popper,\n strategy: 'absolute',\n placement: state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'popperOffsets',\n enabled: true,\n phase: 'read',\n fn: popperOffsets,\n data: {}\n};", "export default function getAltAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}", "import { top, left, right, bottom, start } from \"../enums.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport getAltAxis from \"../utils/getAltAxis.js\";\nimport { within, withinMaxClamp } from \"../utils/within.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport getVariation from \"../utils/getVariation.js\";\nimport getFreshSideObject from \"../utils/getFreshSideObject.js\";\nimport { min as mathMin, max as mathMax } from \"../utils/math.js\";\n\nfunction preventOverflow(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n padding = options.padding,\n _options$tether = options.tether,\n tether = _options$tether === void 0 ? true : _options$tether,\n _options$tetherOffset = options.tetherOffset,\n tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;\n var overflow = detectOverflow(state, {\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n altBoundary: altBoundary\n });\n var basePlacement = getBasePlacement(state.placement);\n var variation = getVariation(state.placement);\n var isBasePlacement = !variation;\n var mainAxis = getMainAxisFromPlacement(basePlacement);\n var altAxis = getAltAxis(mainAxis);\n var popperOffsets = state.modifiersData.popperOffsets;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {\n placement: state.placement\n })) : tetherOffset;\n var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {\n mainAxis: tetherOffsetValue,\n altAxis: tetherOffsetValue\n } : Object.assign({\n mainAxis: 0,\n altAxis: 0\n }, tetherOffsetValue);\n var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;\n var data = {\n x: 0,\n y: 0\n };\n\n if (!popperOffsets) {\n return;\n }\n\n if (checkMainAxis) {\n var _offsetModifierState$;\n\n var mainSide = mainAxis === 'y' ? top : left;\n var altSide = mainAxis === 'y' ? bottom : right;\n var len = mainAxis === 'y' ? 'height' : 'width';\n var offset = popperOffsets[mainAxis];\n var min = offset + overflow[mainSide];\n var max = offset - overflow[altSide];\n var additive = tether ? -popperRect[len] / 2 : 0;\n var minLen = variation === start ? referenceRect[len] : popperRect[len];\n var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go\n // outside the reference bounds\n\n var arrowElement = state.elements.arrow;\n var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {\n width: 0,\n height: 0\n };\n var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();\n var arrowPaddingMin = arrowPaddingObject[mainSide];\n var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want\n // to include its full size in the calculation. If the reference is small\n // and near the edge of a boundary, the popper can overflow even if the\n // reference is not overflowing as well (e.g. virtual elements with no\n // width or height)\n\n var arrowLen = within(0, referenceRect[len], arrowRect[len]);\n var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;\n var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;\n var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);\n var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;\n var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;\n var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;\n var tetherMax = offset + maxOffset - offsetModifierValue;\n var preventedOffset = within(tether ? mathMin(min, tetherMin) : min, offset, tether ? mathMax(max, tetherMax) : max);\n popperOffsets[mainAxis] = preventedOffset;\n data[mainAxis] = preventedOffset - offset;\n }\n\n if (checkAltAxis) {\n var _offsetModifierState$2;\n\n var _mainSide = mainAxis === 'x' ? top : left;\n\n var _altSide = mainAxis === 'x' ? bottom : right;\n\n var _offset = popperOffsets[altAxis];\n\n var _len = altAxis === 'y' ? 'height' : 'width';\n\n var _min = _offset + overflow[_mainSide];\n\n var _max = _offset - overflow[_altSide];\n\n var isOriginSide = [top, left].indexOf(basePlacement) !== -1;\n\n var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;\n\n var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;\n\n var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;\n\n var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);\n\n popperOffsets[altAxis] = _preventedOffset;\n data[altAxis] = _preventedOffset - _offset;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'preventOverflow',\n enabled: true,\n phase: 'main',\n fn: preventOverflow,\n requiresIfExists: ['offset']\n};", "export default function getHTMLElementScroll(element) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n}", "import getWindowScroll from \"./getWindowScroll.js\";\nimport getWindow from \"./getWindow.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getHTMLElementScroll from \"./getHTMLElementScroll.js\";\nexport default function getNodeScroll(node) {\n if (node === getWindow(node) || !isHTMLElement(node)) {\n return getWindowScroll(node);\n } else {\n return getHTMLElementScroll(node);\n }\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getNodeScroll from \"./getNodeScroll.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport isScrollParent from \"./isScrollParent.js\";\nimport { round } from \"../utils/math.js\";\n\nfunction isElementScaled(element) {\n var rect = element.getBoundingClientRect();\n var scaleX = round(rect.width) / element.offsetWidth || 1;\n var scaleY = round(rect.height) / element.offsetHeight || 1;\n return scaleX !== 1 || scaleY !== 1;\n} // Returns the composite rect of an element relative to its offsetParent.\n// Composite means it takes into account transforms as well as layout.\n\n\nexport default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n\n var isOffsetParentAnElement = isHTMLElement(offsetParent);\n var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);\n var documentElement = getDocumentElement(offsetParent);\n var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);\n var scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n var offsets = {\n x: 0,\n y: 0\n };\n\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078\n isScrollParent(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n\n if (isHTMLElement(offsetParent)) {\n offsets = getBoundingClientRect(offsetParent, true);\n offsets.x += offsetParent.clientLeft;\n offsets.y += offsetParent.clientTop;\n } else if (documentElement) {\n offsets.x = getWindowScrollBarX(documentElement);\n }\n }\n\n return {\n x: rect.left + scroll.scrollLeft - offsets.x,\n y: rect.top + scroll.scrollTop - offsets.y,\n width: rect.width,\n height: rect.height\n };\n}", "import { modifierPhases } from \"../enums.js\"; // source: https://stackoverflow.com/questions/49875255\n\nfunction order(modifiers) {\n var map = new Map();\n var visited = new Set();\n var result = [];\n modifiers.forEach(function (modifier) {\n map.set(modifier.name, modifier);\n }); // On visiting object, check for its dependencies and visit them recursively\n\n function sort(modifier) {\n visited.add(modifier.name);\n var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);\n requires.forEach(function (dep) {\n if (!visited.has(dep)) {\n var depModifier = map.get(dep);\n\n if (depModifier) {\n sort(depModifier);\n }\n }\n });\n result.push(modifier);\n }\n\n modifiers.forEach(function (modifier) {\n if (!visited.has(modifier.name)) {\n // check for visited object\n sort(modifier);\n }\n });\n return result;\n}\n\nexport default function orderModifiers(modifiers) {\n // order based on dependencies\n var orderedModifiers = order(modifiers); // order based on phase\n\n return modifierPhases.reduce(function (acc, phase) {\n return acc.concat(orderedModifiers.filter(function (modifier) {\n return modifier.phase === phase;\n }));\n }, []);\n}", "export default function debounce(fn) {\n var pending;\n return function () {\n if (!pending) {\n pending = new Promise(function (resolve) {\n Promise.resolve().then(function () {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}", "export default function mergeByName(modifiers) {\n var merged = modifiers.reduce(function (merged, current) {\n var existing = merged[current.name];\n merged[current.name] = existing ? Object.assign({}, existing, current, {\n options: Object.assign({}, existing.options, current.options),\n data: Object.assign({}, existing.data, current.data)\n }) : current;\n return merged;\n }, {}); // IE11 does not support Object.values\n\n return Object.keys(merged).map(function (key) {\n return merged[key];\n });\n}", "import getCompositeRect from \"./dom-utils/getCompositeRect.js\";\nimport getLayoutRect from \"./dom-utils/getLayoutRect.js\";\nimport listScrollParents from \"./dom-utils/listScrollParents.js\";\nimport getOffsetParent from \"./dom-utils/getOffsetParent.js\";\nimport getComputedStyle from \"./dom-utils/getComputedStyle.js\";\nimport orderModifiers from \"./utils/orderModifiers.js\";\nimport debounce from \"./utils/debounce.js\";\nimport validateModifiers from \"./utils/validateModifiers.js\";\nimport uniqueBy from \"./utils/uniqueBy.js\";\nimport getBasePlacement from \"./utils/getBasePlacement.js\";\nimport mergeByName from \"./utils/mergeByName.js\";\nimport detectOverflow from \"./utils/detectOverflow.js\";\nimport { isElement } from \"./dom-utils/instanceOf.js\";\nimport { auto } from \"./enums.js\";\nvar INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';\nvar INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';\nvar DEFAULT_OPTIONS = {\n placement: 'bottom',\n modifiers: [],\n strategy: 'absolute'\n};\n\nfunction areValidElements() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return !args.some(function (element) {\n return !(element && typeof element.getBoundingClientRect === 'function');\n });\n}\n\nexport function popperGenerator(generatorOptions) {\n if (generatorOptions === void 0) {\n generatorOptions = {};\n }\n\n var _generatorOptions = generatorOptions,\n _generatorOptions$def = _generatorOptions.defaultModifiers,\n defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,\n _generatorOptions$def2 = _generatorOptions.defaultOptions,\n defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;\n return function createPopper(reference, popper, options) {\n if (options === void 0) {\n options = defaultOptions;\n }\n\n var state = {\n placement: 'bottom',\n orderedModifiers: [],\n options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),\n modifiersData: {},\n elements: {\n reference: reference,\n popper: popper\n },\n attributes: {},\n styles: {}\n };\n var effectCleanupFns = [];\n var isDestroyed = false;\n var instance = {\n state: state,\n setOptions: function setOptions(setOptionsAction) {\n var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;\n cleanupModifierEffects();\n state.options = Object.assign({}, defaultOptions, state.options, options);\n state.scrollParents = {\n reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],\n popper: listScrollParents(popper)\n }; // Orders the modifiers based on their dependencies and `phase`\n // properties\n\n var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers\n\n state.orderedModifiers = orderedModifiers.filter(function (m) {\n return m.enabled;\n }); // Validate the provided modifiers so that the consumer will get warned\n // if one of the modifiers is invalid for any reason\n\n if (process.env.NODE_ENV !== \"production\") {\n var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {\n var name = _ref.name;\n return name;\n });\n validateModifiers(modifiers);\n\n if (getBasePlacement(state.options.placement) === auto) {\n var flipModifier = state.orderedModifiers.find(function (_ref2) {\n var name = _ref2.name;\n return name === 'flip';\n });\n\n if (!flipModifier) {\n console.error(['Popper: \"auto\" placements require the \"flip\" modifier be', 'present and enabled to work.'].join(' '));\n }\n }\n\n var _getComputedStyle = getComputedStyle(popper),\n marginTop = _getComputedStyle.marginTop,\n marginRight = _getComputedStyle.marginRight,\n marginBottom = _getComputedStyle.marginBottom,\n marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can\n // cause bugs with positioning, so we'll warn the consumer\n\n\n if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {\n return parseFloat(margin);\n })) {\n console.warn(['Popper: CSS \"margin\" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));\n }\n }\n\n runModifierEffects();\n return instance.update();\n },\n // Sync update \u2013 it will always be executed, even if not necessary. This\n // is useful for low frequency updates where sync behavior simplifies the\n // logic.\n // For high frequency updates (e.g. `resize` and `scroll` events), always\n // prefer the async Popper#update method\n forceUpdate: function forceUpdate() {\n if (isDestroyed) {\n return;\n }\n\n var _state$elements = state.elements,\n reference = _state$elements.reference,\n popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements\n // anymore\n\n if (!areValidElements(reference, popper)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(INVALID_ELEMENT_ERROR);\n }\n\n return;\n } // Store the reference and popper rects to be read by modifiers\n\n\n state.rects = {\n reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),\n popper: getLayoutRect(popper)\n }; // Modifiers have the ability to reset the current update cycle. The\n // most common use case for this is the `flip` modifier changing the\n // placement, which then needs to re-run all the modifiers, because the\n // logic was previously ran for the previous placement and is therefore\n // stale/incorrect\n\n state.reset = false;\n state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier\n // is filled with the initial data specified by the modifier. This means\n // it doesn't persist and is fresh on each update.\n // To ensure persistent data, use `${name}#persistent`\n\n state.orderedModifiers.forEach(function (modifier) {\n return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);\n });\n var __debug_loops__ = 0;\n\n for (var index = 0; index < state.orderedModifiers.length; index++) {\n if (process.env.NODE_ENV !== \"production\") {\n __debug_loops__ += 1;\n\n if (__debug_loops__ > 100) {\n console.error(INFINITE_LOOP_ERROR);\n break;\n }\n }\n\n if (state.reset === true) {\n state.reset = false;\n index = -1;\n continue;\n }\n\n var _state$orderedModifie = state.orderedModifiers[index],\n fn = _state$orderedModifie.fn,\n _state$orderedModifie2 = _state$orderedModifie.options,\n _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,\n name = _state$orderedModifie.name;\n\n if (typeof fn === 'function') {\n state = fn({\n state: state,\n options: _options,\n name: name,\n instance: instance\n }) || state;\n }\n }\n },\n // Async and optimistically optimized update \u2013 it will not be executed if\n // not necessary (debounced to run at most once-per-tick)\n update: debounce(function () {\n return new Promise(function (resolve) {\n instance.forceUpdate();\n resolve(state);\n });\n }),\n destroy: function destroy() {\n cleanupModifierEffects();\n isDestroyed = true;\n }\n };\n\n if (!areValidElements(reference, popper)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(INVALID_ELEMENT_ERROR);\n }\n\n return instance;\n }\n\n instance.setOptions(options).then(function (state) {\n if (!isDestroyed && options.onFirstUpdate) {\n options.onFirstUpdate(state);\n }\n }); // Modifiers have the ability to execute arbitrary code before the first\n // update cycle runs. They will be executed in the same order as the update\n // cycle. This is useful when a modifier adds some persistent data that\n // other modifiers need to use, but the modifier is run after the dependent\n // one.\n\n function runModifierEffects() {\n state.orderedModifiers.forEach(function (_ref3) {\n var name = _ref3.name,\n _ref3$options = _ref3.options,\n options = _ref3$options === void 0 ? {} : _ref3$options,\n effect = _ref3.effect;\n\n if (typeof effect === 'function') {\n var cleanupFn = effect({\n state: state,\n name: name,\n instance: instance,\n options: options\n });\n\n var noopFn = function noopFn() {};\n\n effectCleanupFns.push(cleanupFn || noopFn);\n }\n });\n }\n\n function cleanupModifierEffects() {\n effectCleanupFns.forEach(function (fn) {\n return fn();\n });\n effectCleanupFns = [];\n }\n\n return instance;\n };\n}\nexport var createPopper = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules\n\nexport { detectOverflow };", "import { popperGenerator, detectOverflow } from \"./createPopper.js\";\nimport eventListeners from \"./modifiers/eventListeners.js\";\nimport popperOffsets from \"./modifiers/popperOffsets.js\";\nimport computeStyles from \"./modifiers/computeStyles.js\";\nimport applyStyles from \"./modifiers/applyStyles.js\";\nimport offset from \"./modifiers/offset.js\";\nimport flip from \"./modifiers/flip.js\";\nimport preventOverflow from \"./modifiers/preventOverflow.js\";\nimport arrow from \"./modifiers/arrow.js\";\nimport hide from \"./modifiers/hide.js\";\nvar defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles, offset, flip, preventOverflow, arrow, hide];\nvar createPopper = /*#__PURE__*/popperGenerator({\n defaultModifiers: defaultModifiers\n}); // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper, popperGenerator, defaultModifiers, detectOverflow }; // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper as createPopperLite } from \"./popper-lite.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport * from \"./modifiers/index.js\";", "export const ROUND_ARROW =\n '';\n\nexport const BOX_CLASS = `__NAMESPACE_PREFIX__-box`;\nexport const CONTENT_CLASS = `__NAMESPACE_PREFIX__-content`;\nexport const BACKDROP_CLASS = `__NAMESPACE_PREFIX__-backdrop`;\nexport const ARROW_CLASS = `__NAMESPACE_PREFIX__-arrow`;\nexport const SVG_ARROW_CLASS = `__NAMESPACE_PREFIX__-svg-arrow`;\n\nexport const TOUCH_OPTIONS = {passive: true, capture: true};\n\nexport const TIPPY_DEFAULT_APPEND_TO = () => document.body;\n", "import {BasePlacement, Placement} from './types';\n\nexport function hasOwnProperty(\n obj: Record,\n key: string\n): boolean {\n return {}.hasOwnProperty.call(obj, key);\n}\n\nexport function getValueAtIndexOrReturn(\n value: T | [T | null, T | null],\n index: number,\n defaultValue: T | [T, T]\n): T {\n if (Array.isArray(value)) {\n const v = value[index];\n return v == null\n ? Array.isArray(defaultValue)\n ? defaultValue[index]\n : defaultValue\n : v;\n }\n\n return value;\n}\n\nexport function isType(value: any, type: string): boolean {\n const str = {}.toString.call(value);\n return str.indexOf('[object') === 0 && str.indexOf(`${type}]`) > -1;\n}\n\nexport function invokeWithArgsOrReturn(value: any, args: any[]): any {\n return typeof value === 'function' ? value(...args) : value;\n}\n\nexport function debounce(\n fn: (arg: T) => void,\n ms: number\n): (arg: T) => void {\n // Avoid wrapping in `setTimeout` if ms is 0 anyway\n if (ms === 0) {\n return fn;\n }\n\n let timeout: any;\n\n return (arg): void => {\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n fn(arg);\n }, ms);\n };\n}\n\nexport function removeProperties(obj: T, keys: string[]): Partial {\n const clone = {...obj};\n keys.forEach((key) => {\n delete (clone as any)[key];\n });\n return clone;\n}\n\nexport function splitBySpaces(value: string): string[] {\n return value.split(/\\s+/).filter(Boolean);\n}\n\nexport function normalizeToArray(value: T | T[]): T[] {\n return ([] as T[]).concat(value);\n}\n\nexport function pushIfUnique(arr: T[], value: T): void {\n if (arr.indexOf(value) === -1) {\n arr.push(value);\n }\n}\n\nexport function appendPxIfNumber(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nexport function unique(arr: T[]): T[] {\n return arr.filter((item, index) => arr.indexOf(item) === index);\n}\n\nexport function getNumber(value: string | number): number {\n return typeof value === 'number' ? value : parseFloat(value);\n}\n\nexport function getBasePlacement(placement: Placement): BasePlacement {\n return placement.split('-')[0] as BasePlacement;\n}\n\nexport function arrayFrom(value: ArrayLike): any[] {\n return [].slice.call(value);\n}\n\nexport function removeUndefinedProps(\n obj: Record\n): Partial> {\n return Object.keys(obj).reduce((acc, key) => {\n if (obj[key] !== undefined) {\n (acc as any)[key] = obj[key];\n }\n\n return acc;\n }, {});\n}\n", "import {ReferenceElement, Targets} from './types';\nimport {PopperTreeData} from './types-internal';\nimport {arrayFrom, isType, normalizeToArray, getBasePlacement} from './utils';\n\nexport function div(): HTMLDivElement {\n return document.createElement('div');\n}\n\nexport function isElement(value: unknown): value is Element | DocumentFragment {\n return ['Element', 'Fragment'].some((type) => isType(value, type));\n}\n\nexport function isNodeList(value: unknown): value is NodeList {\n return isType(value, 'NodeList');\n}\n\nexport function isMouseEvent(value: unknown): value is MouseEvent {\n return isType(value, 'MouseEvent');\n}\n\nexport function isReferenceElement(value: any): value is ReferenceElement {\n return !!(value && value._tippy && value._tippy.reference === value);\n}\n\nexport function getArrayOfElements(value: Targets): Element[] {\n if (isElement(value)) {\n return [value];\n }\n\n if (isNodeList(value)) {\n return arrayFrom(value);\n }\n\n if (Array.isArray(value)) {\n return value;\n }\n\n return arrayFrom(document.querySelectorAll(value));\n}\n\nexport function setTransitionDuration(\n els: (HTMLDivElement | null)[],\n value: number\n): void {\n els.forEach((el) => {\n if (el) {\n el.style.transitionDuration = `${value}ms`;\n }\n });\n}\n\nexport function setVisibilityState(\n els: (HTMLDivElement | null)[],\n state: 'visible' | 'hidden'\n): void {\n els.forEach((el) => {\n if (el) {\n el.setAttribute('data-state', state);\n }\n });\n}\n\nexport function getOwnerDocument(\n elementOrElements: Element | Element[]\n): Document {\n const [element] = normalizeToArray(elementOrElements);\n\n // Elements created via a have an ownerDocument with no reference to the body\n return element?.ownerDocument?.body ? element.ownerDocument : document;\n}\n\nexport function isCursorOutsideInteractiveBorder(\n popperTreeData: PopperTreeData[],\n event: MouseEvent\n): boolean {\n const {clientX, clientY} = event;\n\n return popperTreeData.every(({popperRect, popperState, props}) => {\n const {interactiveBorder} = props;\n const basePlacement = getBasePlacement(popperState.placement);\n const offsetData = popperState.modifiersData.offset;\n\n if (!offsetData) {\n return true;\n }\n\n const topDistance = basePlacement === 'bottom' ? offsetData.top!.y : 0;\n const bottomDistance = basePlacement === 'top' ? offsetData.bottom!.y : 0;\n const leftDistance = basePlacement === 'right' ? offsetData.left!.x : 0;\n const rightDistance = basePlacement === 'left' ? offsetData.right!.x : 0;\n\n const exceedsTop =\n popperRect.top - clientY + topDistance > interactiveBorder;\n const exceedsBottom =\n clientY - popperRect.bottom - bottomDistance > interactiveBorder;\n const exceedsLeft =\n popperRect.left - clientX + leftDistance > interactiveBorder;\n const exceedsRight =\n clientX - popperRect.right - rightDistance > interactiveBorder;\n\n return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;\n });\n}\n\nexport function updateTransitionEndListener(\n box: HTMLDivElement,\n action: 'add' | 'remove',\n listener: (event: TransitionEvent) => void\n): void {\n const method = `${action}EventListener` as\n | 'addEventListener'\n | 'removeEventListener';\n\n // some browsers apparently support `transition` (unprefixed) but only fire\n // `webkitTransitionEnd`...\n ['transitionend', 'webkitTransitionEnd'].forEach((event) => {\n box[method](event, listener as EventListener);\n });\n}\n\n/**\n * Compared to xxx.contains, this function works for dom structures with shadow\n * dom\n */\nexport function actualContains(parent: Element, child: Element): boolean {\n let target = child;\n while (target) {\n if (parent.contains(target)) {\n return true;\n }\n target = (target.getRootNode?.() as any)?.host;\n }\n return false;\n}\n", "import {TOUCH_OPTIONS} from './constants';\nimport {isReferenceElement} from './dom-utils';\n\nexport const currentInput = {isTouch: false};\nlet lastMouseMoveTime = 0;\n\n/**\n * When a `touchstart` event is fired, it's assumed the user is using touch\n * input. We'll bind a `mousemove` event listener to listen for mouse input in\n * the future. This way, the `isTouch` property is fully dynamic and will handle\n * hybrid devices that use a mix of touch + mouse input.\n */\nexport function onDocumentTouchStart(): void {\n if (currentInput.isTouch) {\n return;\n }\n\n currentInput.isTouch = true;\n\n if (window.performance) {\n document.addEventListener('mousemove', onDocumentMouseMove);\n }\n}\n\n/**\n * When two `mousemove` event are fired consecutively within 20ms, it's assumed\n * the user is using mouse input again. `mousemove` can fire on touch devices as\n * well, but very rarely that quickly.\n */\nexport function onDocumentMouseMove(): void {\n const now = performance.now();\n\n if (now - lastMouseMoveTime < 20) {\n currentInput.isTouch = false;\n\n document.removeEventListener('mousemove', onDocumentMouseMove);\n }\n\n lastMouseMoveTime = now;\n}\n\n/**\n * When an element is in focus and has a tippy, leaving the tab/window and\n * returning causes it to show again. For mouse users this is unexpected, but\n * for keyboard use it makes sense.\n * TODO: find a better technique to solve this problem\n */\nexport function onWindowBlur(): void {\n const activeElement = document.activeElement as HTMLElement | null;\n\n if (isReferenceElement(activeElement)) {\n const instance = activeElement._tippy!;\n\n if (activeElement.blur && !instance.state.isVisible) {\n activeElement.blur();\n }\n }\n}\n\nexport default function bindGlobalEventListeners(): void {\n document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);\n window.addEventListener('blur', onWindowBlur);\n}\n", "export const isBrowser =\n typeof window !== 'undefined' && typeof document !== 'undefined';\n\nexport const isIE11 = isBrowser\n ? // @ts-ignore\n !!window.msCrypto\n : false;\n", "import {Targets} from './types';\n\nexport function createMemoryLeakWarning(method: string): string {\n const txt = method === 'destroy' ? 'n already-' : ' ';\n\n return [\n `${method}() was called on a${txt}destroyed instance. This is a no-op but`,\n 'indicates a potential memory leak.',\n ].join(' ');\n}\n\nexport function clean(value: string): string {\n const spacesAndTabs = /[ \\t]{2,}/g;\n const lineStartWithSpaces = /^[ \\t]*/gm;\n\n return value\n .replace(spacesAndTabs, ' ')\n .replace(lineStartWithSpaces, '')\n .trim();\n}\n\nfunction getDevMessage(message: string): string {\n return clean(`\n %ctippy.js\n\n %c${clean(message)}\n\n %c👷 This is a development-only message. It will be removed in production.\n `);\n}\n\nexport function getFormattedMessage(message: string): string[] {\n return [\n getDevMessage(message),\n // title\n 'color: #00C584; font-size: 1.3em; font-weight: bold;',\n // message\n 'line-height: 1.5',\n // footer\n 'color: #a6a095;',\n ];\n}\n\n// Assume warnings and errors never have the same message\nlet visitedMessages: Set;\nif (__DEV__) {\n resetVisitedMessages();\n}\n\nexport function resetVisitedMessages(): void {\n visitedMessages = new Set();\n}\n\nexport function warnWhen(condition: boolean, message: string): void {\n if (condition && !visitedMessages.has(message)) {\n visitedMessages.add(message);\n console.warn(...getFormattedMessage(message));\n }\n}\n\nexport function errorWhen(condition: boolean, message: string): void {\n if (condition && !visitedMessages.has(message)) {\n visitedMessages.add(message);\n console.error(...getFormattedMessage(message));\n }\n}\n\nexport function validateTargets(targets: Targets): void {\n const didPassFalsyValue = !targets;\n const didPassPlainObject =\n Object.prototype.toString.call(targets) === '[object Object]' &&\n !(targets as any).addEventListener;\n\n errorWhen(\n didPassFalsyValue,\n [\n 'tippy() was passed',\n '`' + String(targets) + '`',\n 'as its targets (first) argument. Valid types are: String, Element,',\n 'Element[], or NodeList.',\n ].join(' ')\n );\n\n errorWhen(\n didPassPlainObject,\n [\n 'tippy() was passed a plain object which is not supported as an argument',\n 'for virtual positioning. Use props.getReferenceClientRect instead.',\n ].join(' ')\n );\n}\n", "import {DefaultProps, Plugin, Props, ReferenceElement, Tippy} from './types';\nimport {\n hasOwnProperty,\n removeProperties,\n invokeWithArgsOrReturn,\n} from './utils';\nimport {warnWhen} from './validation';\nimport {TIPPY_DEFAULT_APPEND_TO} from './constants';\n\nconst pluginProps = {\n animateFill: false,\n followCursor: false,\n inlinePositioning: false,\n sticky: false,\n};\n\nconst renderProps = {\n allowHTML: false,\n animation: 'fade',\n arrow: true,\n content: '',\n inertia: false,\n maxWidth: 350,\n role: 'tooltip',\n theme: '',\n zIndex: 9999,\n};\n\nexport const defaultProps: DefaultProps = {\n appendTo: TIPPY_DEFAULT_APPEND_TO,\n aria: {\n content: 'auto',\n expanded: 'auto',\n },\n delay: 0,\n duration: [300, 250],\n getReferenceClientRect: null,\n hideOnClick: true,\n ignoreAttributes: false,\n interactive: false,\n interactiveBorder: 2,\n interactiveDebounce: 0,\n moveTransition: '',\n offset: [0, 10],\n onAfterUpdate() {},\n onBeforeUpdate() {},\n onCreate() {},\n onDestroy() {},\n onHidden() {},\n onHide() {},\n onMount() {},\n onShow() {},\n onShown() {},\n onTrigger() {},\n onUntrigger() {},\n onClickOutside() {},\n placement: 'top',\n plugins: [],\n popperOptions: {},\n render: null,\n showOnCreate: false,\n touch: true,\n trigger: 'mouseenter focus',\n triggerTarget: null,\n ...pluginProps,\n ...renderProps,\n};\n\nconst defaultKeys = Object.keys(defaultProps);\n\nexport const setDefaultProps: Tippy['setDefaultProps'] = (partialProps) => {\n /* istanbul ignore else */\n if (__DEV__) {\n validateProps(partialProps, []);\n }\n\n const keys = Object.keys(partialProps) as Array;\n keys.forEach((key) => {\n (defaultProps as any)[key] = partialProps[key];\n });\n};\n\nexport function getExtendedPassedProps(\n passedProps: Partial & Record\n): Partial {\n const plugins = passedProps.plugins || [];\n const pluginProps = plugins.reduce>((acc, plugin) => {\n const {name, defaultValue} = plugin;\n\n if (name) {\n acc[name] =\n passedProps[name] !== undefined\n ? passedProps[name]\n : (defaultProps as any)[name] ?? defaultValue;\n }\n\n return acc;\n }, {});\n\n return {\n ...passedProps,\n ...pluginProps,\n };\n}\n\nexport function getDataAttributeProps(\n reference: ReferenceElement,\n plugins: Plugin[]\n): Record {\n const propKeys = plugins\n ? Object.keys(getExtendedPassedProps({...defaultProps, plugins}))\n : defaultKeys;\n\n const props = propKeys.reduce(\n (acc: Partial & Record, key) => {\n const valueAsString = (\n reference.getAttribute(`data-tippy-${key}`) || ''\n ).trim();\n\n if (!valueAsString) {\n return acc;\n }\n\n if (key === 'content') {\n acc[key] = valueAsString;\n } else {\n try {\n acc[key] = JSON.parse(valueAsString);\n } catch (e) {\n acc[key] = valueAsString;\n }\n }\n\n return acc;\n },\n {}\n );\n\n return props;\n}\n\nexport function evaluateProps(\n reference: ReferenceElement,\n props: Props\n): Props {\n const out = {\n ...props,\n content: invokeWithArgsOrReturn(props.content, [reference]),\n ...(props.ignoreAttributes\n ? {}\n : getDataAttributeProps(reference, props.plugins)),\n };\n\n out.aria = {\n ...defaultProps.aria,\n ...out.aria,\n };\n\n out.aria = {\n expanded:\n out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,\n content:\n out.aria.content === 'auto'\n ? props.interactive\n ? null\n : 'describedby'\n : out.aria.content,\n };\n\n return out;\n}\n\nexport function validateProps(\n partialProps: Partial = {},\n plugins: Plugin[] = []\n): void {\n const keys = Object.keys(partialProps) as Array;\n keys.forEach((prop) => {\n const nonPluginProps = removeProperties(\n defaultProps,\n Object.keys(pluginProps)\n );\n\n let didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop);\n\n // Check if the prop exists in `plugins`\n if (didPassUnknownProp) {\n didPassUnknownProp =\n plugins.filter((plugin) => plugin.name === prop).length === 0;\n }\n\n warnWhen(\n didPassUnknownProp,\n [\n `\\`${prop}\\``,\n \"is not a valid prop. You may have spelled it incorrectly, or if it's\",\n 'a plugin, forgot to pass it in an array as props.plugins.',\n '\\n\\n',\n 'All props: https://atomiks.github.io/tippyjs/v6/all-props/\\n',\n 'Plugins: https://atomiks.github.io/tippyjs/v6/plugins/',\n ].join(' ')\n );\n });\n}\n", "import {\n ARROW_CLASS,\n BACKDROP_CLASS,\n BOX_CLASS,\n CONTENT_CLASS,\n SVG_ARROW_CLASS,\n} from './constants';\nimport {div, isElement} from './dom-utils';\nimport {Instance, PopperElement, Props} from './types';\nimport {PopperChildren} from './types-internal';\nimport {arrayFrom} from './utils';\n\n// Firefox extensions don't allow .innerHTML = \"...\" property. This tricks it.\nconst innerHTML = (): 'innerHTML' => 'innerHTML';\n\nfunction dangerouslySetInnerHTML(element: Element, html: string): void {\n element[innerHTML()] = html;\n}\n\nfunction createArrowElement(value: Props['arrow']): HTMLDivElement {\n const arrow = div();\n\n if (value === true) {\n arrow.className = ARROW_CLASS;\n } else {\n arrow.className = SVG_ARROW_CLASS;\n\n if (isElement(value)) {\n arrow.appendChild(value);\n } else {\n dangerouslySetInnerHTML(arrow, value as string);\n }\n }\n\n return arrow;\n}\n\nexport function setContent(content: HTMLDivElement, props: Props): void {\n if (isElement(props.content)) {\n dangerouslySetInnerHTML(content, '');\n content.appendChild(props.content);\n } else if (typeof props.content !== 'function') {\n if (props.allowHTML) {\n dangerouslySetInnerHTML(content, props.content);\n } else {\n content.textContent = props.content;\n }\n }\n}\n\nexport function getChildren(popper: PopperElement): PopperChildren {\n const box = popper.firstElementChild as HTMLDivElement;\n const boxChildren = arrayFrom(box.children);\n\n return {\n box,\n content: boxChildren.find((node) => node.classList.contains(CONTENT_CLASS)),\n arrow: boxChildren.find(\n (node) =>\n node.classList.contains(ARROW_CLASS) ||\n node.classList.contains(SVG_ARROW_CLASS)\n ),\n backdrop: boxChildren.find((node) =>\n node.classList.contains(BACKDROP_CLASS)\n ),\n };\n}\n\nexport function render(\n instance: Instance\n): {\n popper: PopperElement;\n onUpdate?: (prevProps: Props, nextProps: Props) => void;\n} {\n const popper = div();\n\n const box = div();\n box.className = BOX_CLASS;\n box.setAttribute('data-state', 'hidden');\n box.setAttribute('tabindex', '-1');\n\n const content = div();\n content.className = CONTENT_CLASS;\n content.setAttribute('data-state', 'hidden');\n\n setContent(content, instance.props);\n\n popper.appendChild(box);\n box.appendChild(content);\n\n onUpdate(instance.props, instance.props);\n\n function onUpdate(prevProps: Props, nextProps: Props): void {\n const {box, content, arrow} = getChildren(popper);\n\n if (nextProps.theme) {\n box.setAttribute('data-theme', nextProps.theme);\n } else {\n box.removeAttribute('data-theme');\n }\n\n if (typeof nextProps.animation === 'string') {\n box.setAttribute('data-animation', nextProps.animation);\n } else {\n box.removeAttribute('data-animation');\n }\n\n if (nextProps.inertia) {\n box.setAttribute('data-inertia', '');\n } else {\n box.removeAttribute('data-inertia');\n }\n\n box.style.maxWidth =\n typeof nextProps.maxWidth === 'number'\n ? `${nextProps.maxWidth}px`\n : nextProps.maxWidth;\n\n if (nextProps.role) {\n box.setAttribute('role', nextProps.role);\n } else {\n box.removeAttribute('role');\n }\n\n if (\n prevProps.content !== nextProps.content ||\n prevProps.allowHTML !== nextProps.allowHTML\n ) {\n setContent(content, instance.props);\n }\n\n if (nextProps.arrow) {\n if (!arrow) {\n box.appendChild(createArrowElement(nextProps.arrow));\n } else if (prevProps.arrow !== nextProps.arrow) {\n box.removeChild(arrow);\n box.appendChild(createArrowElement(nextProps.arrow));\n }\n } else if (arrow) {\n box.removeChild(arrow!);\n }\n }\n\n return {\n popper,\n onUpdate,\n };\n}\n\n// Runtime check to identify if the render function is the default one; this\n// way we can apply default CSS transitions logic and it can be tree-shaken away\nrender.$$tippy = true;\n", "import {createPopper, StrictModifiers, Modifier} from '@popperjs/core';\nimport {currentInput} from './bindGlobalEventListeners';\nimport {isIE11} from './browser';\nimport {TIPPY_DEFAULT_APPEND_TO, TOUCH_OPTIONS} from './constants';\nimport {\n actualContains,\n div,\n getOwnerDocument,\n isCursorOutsideInteractiveBorder,\n isMouseEvent,\n setTransitionDuration,\n setVisibilityState,\n updateTransitionEndListener,\n} from './dom-utils';\nimport {defaultProps, evaluateProps, getExtendedPassedProps} from './props';\nimport {getChildren} from './template';\nimport {\n Content,\n Instance,\n LifecycleHooks,\n PopperElement,\n Props,\n ReferenceElement,\n} from './types';\nimport {ListenerObject, PopperTreeData, PopperChildren} from './types-internal';\nimport {\n arrayFrom,\n debounce,\n getValueAtIndexOrReturn,\n invokeWithArgsOrReturn,\n normalizeToArray,\n pushIfUnique,\n splitBySpaces,\n unique,\n removeUndefinedProps,\n} from './utils';\nimport {createMemoryLeakWarning, errorWhen, warnWhen} from './validation';\n\nlet idCounter = 1;\nlet mouseMoveListeners: ((event: MouseEvent) => void)[] = [];\n\n// Used by `hideAll()`\nexport let mountedInstances: Instance[] = [];\n\nexport default function createTippy(\n reference: ReferenceElement,\n passedProps: Partial\n): Instance {\n const props = evaluateProps(reference, {\n ...defaultProps,\n ...getExtendedPassedProps(removeUndefinedProps(passedProps)),\n });\n\n // ===========================================================================\n // 🔒 Private members\n // ===========================================================================\n let showTimeout: any;\n let hideTimeout: any;\n let scheduleHideAnimationFrame: number;\n let isVisibleFromClick = false;\n let didHideDueToDocumentMouseDown = false;\n let didTouchMove = false;\n let ignoreOnFirstUpdate = false;\n let lastTriggerEvent: Event | undefined;\n let currentTransitionEndListener: (event: TransitionEvent) => void;\n let onFirstUpdate: () => void;\n let listeners: ListenerObject[] = [];\n let debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);\n let currentTarget: Element;\n\n // ===========================================================================\n // 🔑 Public members\n // ===========================================================================\n const id = idCounter++;\n const popperInstance = null;\n const plugins = unique(props.plugins);\n\n const state = {\n // Is the instance currently enabled?\n isEnabled: true,\n // Is the tippy currently showing and not transitioning out?\n isVisible: false,\n // Has the instance been destroyed?\n isDestroyed: false,\n // Is the tippy currently mounted to the DOM?\n isMounted: false,\n // Has the tippy finished transitioning in?\n isShown: false,\n };\n\n const instance: Instance = {\n // properties\n id,\n reference,\n popper: div(),\n popperInstance,\n props,\n state,\n plugins,\n // methods\n clearDelayTimeouts,\n setProps,\n setContent,\n show,\n hide,\n hideWithInteractivity,\n enable,\n disable,\n unmount,\n destroy,\n };\n\n // TODO: Investigate why this early return causes a TDZ error in the tests —\n // it doesn't seem to happen in the browser\n /* istanbul ignore if */\n if (!props.render) {\n if (__DEV__) {\n errorWhen(true, 'render() function has not been supplied.');\n }\n\n return instance;\n }\n\n // ===========================================================================\n // Initial mutations\n // ===========================================================================\n const {popper, onUpdate} = props.render(instance);\n\n popper.setAttribute('data-__NAMESPACE_PREFIX__-root', '');\n popper.id = `__NAMESPACE_PREFIX__-${instance.id}`;\n\n instance.popper = popper;\n reference._tippy = instance;\n popper._tippy = instance;\n\n const pluginsHooks = plugins.map((plugin) => plugin.fn(instance));\n const hasAriaExpanded = reference.hasAttribute('aria-expanded');\n\n addListeners();\n handleAriaExpandedAttribute();\n handleStyles();\n\n invokeHook('onCreate', [instance]);\n\n if (props.showOnCreate) {\n scheduleShow();\n }\n\n // Prevent a tippy with a delay from hiding if the cursor left then returned\n // before it started hiding\n popper.addEventListener('mouseenter', () => {\n if (instance.props.interactive && instance.state.isVisible) {\n instance.clearDelayTimeouts();\n }\n });\n\n popper.addEventListener('mouseleave', () => {\n if (\n instance.props.interactive &&\n instance.props.trigger.indexOf('mouseenter') >= 0\n ) {\n getDocument().addEventListener('mousemove', debouncedOnMouseMove);\n }\n });\n\n return instance;\n\n // ===========================================================================\n // 🔒 Private methods\n // ===========================================================================\n function getNormalizedTouchSettings(): [string | boolean, number] {\n const {touch} = instance.props;\n return Array.isArray(touch) ? touch : [touch, 0];\n }\n\n function getIsCustomTouchBehavior(): boolean {\n return getNormalizedTouchSettings()[0] === 'hold';\n }\n\n function getIsDefaultRenderFn(): boolean {\n // @ts-ignore\n return !!instance.props.render?.$$tippy;\n }\n\n function getCurrentTarget(): Element {\n return currentTarget || reference;\n }\n\n function getDocument(): Document {\n const parent = getCurrentTarget().parentNode as Element;\n return parent ? getOwnerDocument(parent) : document;\n }\n\n function getDefaultTemplateChildren(): PopperChildren {\n return getChildren(popper);\n }\n\n function getDelay(isShow: boolean): number {\n // For touch or keyboard input, force `0` delay for UX reasons\n // Also if the instance is mounted but not visible (transitioning out),\n // ignore delay\n if (\n (instance.state.isMounted && !instance.state.isVisible) ||\n currentInput.isTouch ||\n (lastTriggerEvent && lastTriggerEvent.type === 'focus')\n ) {\n return 0;\n }\n\n return getValueAtIndexOrReturn(\n instance.props.delay,\n isShow ? 0 : 1,\n defaultProps.delay\n );\n }\n\n function handleStyles(fromHide = false): void {\n popper.style.pointerEvents =\n instance.props.interactive && !fromHide ? '' : 'none';\n popper.style.zIndex = `${instance.props.zIndex}`;\n }\n\n function invokeHook(\n hook: keyof LifecycleHooks,\n args: [Instance, any?],\n shouldInvokePropsHook = true\n ): void {\n pluginsHooks.forEach((pluginHooks) => {\n if (pluginHooks[hook]) {\n pluginHooks[hook]!(...args);\n }\n });\n\n if (shouldInvokePropsHook) {\n instance.props[hook](...args);\n }\n }\n\n function handleAriaContentAttribute(): void {\n const {aria} = instance.props;\n\n if (!aria.content) {\n return;\n }\n\n const attr = `aria-${aria.content}`;\n const id = popper.id;\n const nodes = normalizeToArray(instance.props.triggerTarget || reference);\n\n nodes.forEach((node) => {\n const currentValue = node.getAttribute(attr);\n\n if (instance.state.isVisible) {\n node.setAttribute(attr, currentValue ? `${currentValue} ${id}` : id);\n } else {\n const nextValue = currentValue && currentValue.replace(id, '').trim();\n\n if (nextValue) {\n node.setAttribute(attr, nextValue);\n } else {\n node.removeAttribute(attr);\n }\n }\n });\n }\n\n function handleAriaExpandedAttribute(): void {\n if (hasAriaExpanded || !instance.props.aria.expanded) {\n return;\n }\n\n const nodes = normalizeToArray(instance.props.triggerTarget || reference);\n\n nodes.forEach((node) => {\n if (instance.props.interactive) {\n node.setAttribute(\n 'aria-expanded',\n instance.state.isVisible && node === getCurrentTarget()\n ? 'true'\n : 'false'\n );\n } else {\n node.removeAttribute('aria-expanded');\n }\n });\n }\n\n function cleanupInteractiveMouseListeners(): void {\n getDocument().removeEventListener('mousemove', debouncedOnMouseMove);\n mouseMoveListeners = mouseMoveListeners.filter(\n (listener) => listener !== debouncedOnMouseMove\n );\n }\n\n function onDocumentPress(event: MouseEvent | TouchEvent): void {\n // Moved finger to scroll instead of an intentional tap outside\n if (currentInput.isTouch) {\n if (didTouchMove || event.type === 'mousedown') {\n return;\n }\n }\n\n const actualTarget =\n (event.composedPath && event.composedPath()[0]) || event.target;\n\n // Clicked on interactive popper\n if (\n instance.props.interactive &&\n actualContains(popper, actualTarget as Element)\n ) {\n return;\n }\n\n // Clicked on the event listeners target\n if (\n normalizeToArray(instance.props.triggerTarget || reference).some((el) =>\n actualContains(el, actualTarget as Element)\n )\n ) {\n if (currentInput.isTouch) {\n return;\n }\n\n if (\n instance.state.isVisible &&\n instance.props.trigger.indexOf('click') >= 0\n ) {\n return;\n }\n } else {\n invokeHook('onClickOutside', [instance, event]);\n }\n\n if (instance.props.hideOnClick === true) {\n instance.clearDelayTimeouts();\n instance.hide();\n\n // `mousedown` event is fired right before `focus` if pressing the\n // currentTarget. This lets a tippy with `focus` trigger know that it\n // should not show\n didHideDueToDocumentMouseDown = true;\n setTimeout(() => {\n didHideDueToDocumentMouseDown = false;\n });\n\n // The listener gets added in `scheduleShow()`, but this may be hiding it\n // before it shows, and hide()'s early bail-out behavior can prevent it\n // from being cleaned up\n if (!instance.state.isMounted) {\n removeDocumentPress();\n }\n }\n }\n\n function onTouchMove(): void {\n didTouchMove = true;\n }\n\n function onTouchStart(): void {\n didTouchMove = false;\n }\n\n function addDocumentPress(): void {\n const doc = getDocument();\n doc.addEventListener('mousedown', onDocumentPress, true);\n doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);\n doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);\n doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);\n }\n\n function removeDocumentPress(): void {\n const doc = getDocument();\n doc.removeEventListener('mousedown', onDocumentPress, true);\n doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);\n doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);\n doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);\n }\n\n function onTransitionedOut(duration: number, callback: () => void): void {\n onTransitionEnd(duration, () => {\n if (\n !instance.state.isVisible &&\n popper.parentNode &&\n popper.parentNode.contains(popper)\n ) {\n callback();\n }\n });\n }\n\n function onTransitionedIn(duration: number, callback: () => void): void {\n onTransitionEnd(duration, callback);\n }\n\n function onTransitionEnd(duration: number, callback: () => void): void {\n const box = getDefaultTemplateChildren().box;\n\n function listener(event: TransitionEvent): void {\n if (event.target === box) {\n updateTransitionEndListener(box, 'remove', listener);\n callback();\n }\n }\n\n // Make callback synchronous if duration is 0\n // `transitionend` won't fire otherwise\n if (duration === 0) {\n return callback();\n }\n\n updateTransitionEndListener(box, 'remove', currentTransitionEndListener);\n updateTransitionEndListener(box, 'add', listener);\n\n currentTransitionEndListener = listener;\n }\n\n function on(\n eventType: string,\n handler: EventListener,\n options: boolean | Record = false\n ): void {\n const nodes = normalizeToArray(instance.props.triggerTarget || reference);\n nodes.forEach((node) => {\n node.addEventListener(eventType, handler, options);\n listeners.push({node, eventType, handler, options});\n });\n }\n\n function addListeners(): void {\n if (getIsCustomTouchBehavior()) {\n on('touchstart', onTrigger, {passive: true});\n on('touchend', onMouseLeave as EventListener, {passive: true});\n }\n\n splitBySpaces(instance.props.trigger).forEach((eventType) => {\n if (eventType === 'manual') {\n return;\n }\n\n on(eventType, onTrigger);\n\n switch (eventType) {\n case 'mouseenter':\n on('mouseleave', onMouseLeave as EventListener);\n break;\n case 'focus':\n on(isIE11 ? 'focusout' : 'blur', onBlurOrFocusOut as EventListener);\n break;\n case 'focusin':\n on('focusout', onBlurOrFocusOut as EventListener);\n break;\n }\n });\n }\n\n function removeListeners(): void {\n listeners.forEach(({node, eventType, handler, options}: ListenerObject) => {\n node.removeEventListener(eventType, handler, options);\n });\n listeners = [];\n }\n\n function onTrigger(event: Event): void {\n let shouldScheduleClickHide = false;\n\n if (\n !instance.state.isEnabled ||\n isEventListenerStopped(event) ||\n didHideDueToDocumentMouseDown\n ) {\n return;\n }\n\n const wasFocused = lastTriggerEvent?.type === 'focus';\n\n lastTriggerEvent = event;\n currentTarget = event.currentTarget as Element;\n\n handleAriaExpandedAttribute();\n\n if (!instance.state.isVisible && isMouseEvent(event)) {\n // If scrolling, `mouseenter` events can be fired if the cursor lands\n // over a new target, but `mousemove` events don't get fired. This\n // causes interactive tooltips to get stuck open until the cursor is\n // moved\n mouseMoveListeners.forEach((listener) => listener(event));\n }\n\n // Toggle show/hide when clicking click-triggered tooltips\n if (\n event.type === 'click' &&\n (instance.props.trigger.indexOf('mouseenter') < 0 ||\n isVisibleFromClick) &&\n instance.props.hideOnClick !== false &&\n instance.state.isVisible\n ) {\n shouldScheduleClickHide = true;\n } else {\n scheduleShow(event);\n }\n\n if (event.type === 'click') {\n isVisibleFromClick = !shouldScheduleClickHide;\n }\n\n if (shouldScheduleClickHide && !wasFocused) {\n scheduleHide(event);\n }\n }\n\n function onMouseMove(event: MouseEvent): void {\n const target = event.target as Node;\n const isCursorOverReferenceOrPopper =\n getCurrentTarget().contains(target) || popper.contains(target);\n\n if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {\n return;\n }\n\n const popperTreeData = getNestedPopperTree()\n .concat(popper)\n .map((popper) => {\n const instance = popper._tippy!;\n const state = instance.popperInstance?.state;\n\n if (state) {\n return {\n popperRect: popper.getBoundingClientRect(),\n popperState: state,\n props,\n };\n }\n\n return null;\n })\n .filter(Boolean) as PopperTreeData[];\n\n if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {\n cleanupInteractiveMouseListeners();\n scheduleHide(event);\n }\n }\n\n function onMouseLeave(event: MouseEvent): void {\n const shouldBail =\n isEventListenerStopped(event) ||\n (instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick);\n\n if (shouldBail) {\n return;\n }\n\n if (instance.props.interactive) {\n instance.hideWithInteractivity(event);\n return;\n }\n\n scheduleHide(event);\n }\n\n function onBlurOrFocusOut(event: FocusEvent): void {\n if (\n instance.props.trigger.indexOf('focusin') < 0 &&\n event.target !== getCurrentTarget()\n ) {\n return;\n }\n\n // If focus was moved to within the popper\n if (\n instance.props.interactive &&\n event.relatedTarget &&\n popper.contains(event.relatedTarget as Element)\n ) {\n return;\n }\n\n scheduleHide(event);\n }\n\n function isEventListenerStopped(event: Event): boolean {\n return currentInput.isTouch\n ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0\n : false;\n }\n\n function createPopperInstance(): void {\n destroyPopperInstance();\n\n const {\n popperOptions,\n placement,\n offset,\n getReferenceClientRect,\n moveTransition,\n } = instance.props;\n\n const arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;\n\n const computedReference = getReferenceClientRect\n ? {\n getBoundingClientRect: getReferenceClientRect,\n contextElement:\n getReferenceClientRect.contextElement || getCurrentTarget(),\n }\n : reference;\n\n const tippyModifier: Modifier<'$$tippy', Record> = {\n name: '$$tippy',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles'],\n fn({state}) {\n if (getIsDefaultRenderFn()) {\n const {box} = getDefaultTemplateChildren();\n\n ['placement', 'reference-hidden', 'escaped'].forEach((attr) => {\n if (attr === 'placement') {\n box.setAttribute('data-placement', state.placement);\n } else {\n if (state.attributes.popper[`data-popper-${attr}`]) {\n box.setAttribute(`data-${attr}`, '');\n } else {\n box.removeAttribute(`data-${attr}`);\n }\n }\n });\n\n state.attributes.popper = {};\n }\n },\n };\n\n type TippyModifier = Modifier<'$$tippy', Record>;\n type ExtendedModifiers = StrictModifiers | Partial;\n\n const modifiers: Array = [\n {\n name: 'offset',\n options: {\n offset,\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: {\n top: 2,\n bottom: 2,\n left: 5,\n right: 5,\n },\n },\n },\n {\n name: 'flip',\n options: {\n padding: 5,\n },\n },\n {\n name: 'computeStyles',\n options: {\n adaptive: !moveTransition,\n },\n },\n tippyModifier,\n ];\n\n if (getIsDefaultRenderFn() && arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrow,\n padding: 3,\n },\n });\n }\n\n modifiers.push(...(popperOptions?.modifiers || []));\n\n instance.popperInstance = createPopper(\n computedReference,\n popper,\n {\n ...popperOptions,\n placement,\n onFirstUpdate,\n modifiers,\n }\n );\n }\n\n function destroyPopperInstance(): void {\n if (instance.popperInstance) {\n instance.popperInstance.destroy();\n instance.popperInstance = null;\n }\n }\n\n function mount(): void {\n const {appendTo} = instance.props;\n\n let parentNode: any;\n\n // By default, we'll append the popper to the triggerTargets's parentNode so\n // it's directly after the reference element so the elements inside the\n // tippy can be tabbed to\n // If there are clipping issues, the user can specify a different appendTo\n // and ensure focus management is handled correctly manually\n const node = getCurrentTarget();\n\n if (\n (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO) ||\n appendTo === 'parent'\n ) {\n parentNode = node.parentNode;\n } else {\n parentNode = invokeWithArgsOrReturn(appendTo, [node]);\n }\n\n // The popper element needs to exist on the DOM before its position can be\n // updated as Popper needs to read its dimensions\n if (!parentNode.contains(popper)) {\n parentNode.appendChild(popper);\n }\n\n instance.state.isMounted = true;\n\n createPopperInstance();\n\n /* istanbul ignore else */\n if (__DEV__) {\n // Accessibility check\n warnWhen(\n instance.props.interactive &&\n appendTo === defaultProps.appendTo &&\n node.nextElementSibling !== popper,\n [\n 'Interactive tippy element may not be accessible via keyboard',\n 'navigation because it is not directly after the reference element',\n 'in the DOM source order.',\n '\\n\\n',\n 'Using a wrapper or
tag around the reference element',\n 'solves this by creating a new parentNode context.',\n '\\n\\n',\n 'Specifying `appendTo: document.body` silences this warning, but it',\n 'assumes you are using a focus management solution to handle',\n 'keyboard navigation.',\n '\\n\\n',\n 'See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity',\n ].join(' ')\n );\n }\n }\n\n function getNestedPopperTree(): PopperElement[] {\n return arrayFrom(\n popper.querySelectorAll('[data-__NAMESPACE_PREFIX__-root]')\n );\n }\n\n function scheduleShow(event?: Event): void {\n instance.clearDelayTimeouts();\n\n if (event) {\n invokeHook('onTrigger', [instance, event]);\n }\n\n addDocumentPress();\n\n let delay = getDelay(true);\n const [touchValue, touchDelay] = getNormalizedTouchSettings();\n\n if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {\n delay = touchDelay;\n }\n\n if (delay) {\n showTimeout = setTimeout(() => {\n instance.show();\n }, delay);\n } else {\n instance.show();\n }\n }\n\n function scheduleHide(event: Event): void {\n instance.clearDelayTimeouts();\n\n invokeHook('onUntrigger', [instance, event]);\n\n if (!instance.state.isVisible) {\n removeDocumentPress();\n\n return;\n }\n\n // For interactive tippies, scheduleHide is added to a document.body handler\n // from onMouseLeave so must intercept scheduled hides from mousemove/leave\n // events when trigger contains mouseenter and click, and the tip is\n // currently shown as a result of a click.\n if (\n instance.props.trigger.indexOf('mouseenter') >= 0 &&\n instance.props.trigger.indexOf('click') >= 0 &&\n ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 &&\n isVisibleFromClick\n ) {\n return;\n }\n\n const delay = getDelay(false);\n\n if (delay) {\n hideTimeout = setTimeout(() => {\n if (instance.state.isVisible) {\n instance.hide();\n }\n }, delay);\n } else {\n // Fixes a `transitionend` problem when it fires 1 frame too\n // late sometimes, we don't want hide() to be called.\n scheduleHideAnimationFrame = requestAnimationFrame(() => {\n instance.hide();\n });\n }\n }\n\n // ===========================================================================\n // 🔑 Public methods\n // ===========================================================================\n function enable(): void {\n instance.state.isEnabled = true;\n }\n\n function disable(): void {\n // Disabling the instance should also hide it\n // https://github.com/atomiks/tippy.js-react/issues/106\n instance.hide();\n instance.state.isEnabled = false;\n }\n\n function clearDelayTimeouts(): void {\n clearTimeout(showTimeout);\n clearTimeout(hideTimeout);\n cancelAnimationFrame(scheduleHideAnimationFrame);\n }\n\n function setProps(partialProps: Partial): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));\n }\n\n if (instance.state.isDestroyed) {\n return;\n }\n\n invokeHook('onBeforeUpdate', [instance, partialProps]);\n\n removeListeners();\n\n const prevProps = instance.props;\n const nextProps = evaluateProps(reference, {\n ...prevProps,\n ...removeUndefinedProps(partialProps),\n ignoreAttributes: true,\n });\n\n instance.props = nextProps;\n\n addListeners();\n\n if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {\n cleanupInteractiveMouseListeners();\n debouncedOnMouseMove = debounce(\n onMouseMove,\n nextProps.interactiveDebounce\n );\n }\n\n // Ensure stale aria-expanded attributes are removed\n if (prevProps.triggerTarget && !nextProps.triggerTarget) {\n normalizeToArray(prevProps.triggerTarget).forEach((node) => {\n node.removeAttribute('aria-expanded');\n });\n } else if (nextProps.triggerTarget) {\n reference.removeAttribute('aria-expanded');\n }\n\n handleAriaExpandedAttribute();\n handleStyles();\n\n if (onUpdate) {\n onUpdate(prevProps, nextProps);\n }\n\n if (instance.popperInstance) {\n createPopperInstance();\n\n // Fixes an issue with nested tippies if they are all getting re-rendered,\n // and the nested ones get re-rendered first.\n // https://github.com/atomiks/tippyjs-react/issues/177\n // TODO: find a cleaner / more efficient solution(!)\n getNestedPopperTree().forEach((nestedPopper) => {\n // React (and other UI libs likely) requires a rAF wrapper as it flushes\n // its work in one\n requestAnimationFrame(nestedPopper._tippy!.popperInstance!.forceUpdate);\n });\n }\n\n invokeHook('onAfterUpdate', [instance, partialProps]);\n }\n\n function setContent(content: Content): void {\n instance.setProps({content});\n }\n\n function show(): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));\n }\n\n // Early bail-out\n const isAlreadyVisible = instance.state.isVisible;\n const isDestroyed = instance.state.isDestroyed;\n const isDisabled = !instance.state.isEnabled;\n const isTouchAndTouchDisabled =\n currentInput.isTouch && !instance.props.touch;\n const duration = getValueAtIndexOrReturn(\n instance.props.duration,\n 0,\n defaultProps.duration\n );\n\n if (\n isAlreadyVisible ||\n isDestroyed ||\n isDisabled ||\n isTouchAndTouchDisabled\n ) {\n return;\n }\n\n // Normalize `disabled` behavior across browsers.\n // Firefox allows events on disabled elements, but Chrome doesn't.\n // Using a wrapper element (i.e. ) is recommended.\n if (getCurrentTarget().hasAttribute('disabled')) {\n return;\n }\n\n invokeHook('onShow', [instance], false);\n if (instance.props.onShow(instance) === false) {\n return;\n }\n\n instance.state.isVisible = true;\n\n if (getIsDefaultRenderFn()) {\n popper.style.visibility = 'visible';\n }\n\n handleStyles();\n addDocumentPress();\n\n if (!instance.state.isMounted) {\n popper.style.transition = 'none';\n }\n\n // If flipping to the opposite side after hiding at least once, the\n // animation will use the wrong placement without resetting the duration\n if (getIsDefaultRenderFn()) {\n const {box, content} = getDefaultTemplateChildren();\n setTransitionDuration([box, content], 0);\n }\n\n onFirstUpdate = (): void => {\n if (!instance.state.isVisible || ignoreOnFirstUpdate) {\n return;\n }\n\n ignoreOnFirstUpdate = true;\n\n // reflow\n void popper.offsetHeight;\n\n popper.style.transition = instance.props.moveTransition;\n\n if (getIsDefaultRenderFn() && instance.props.animation) {\n const {box, content} = getDefaultTemplateChildren();\n setTransitionDuration([box, content], duration);\n setVisibilityState([box, content], 'visible');\n }\n\n handleAriaContentAttribute();\n handleAriaExpandedAttribute();\n\n pushIfUnique(mountedInstances, instance);\n\n // certain modifiers (e.g. `maxSize`) require a second update after the\n // popper has been positioned for the first time\n instance.popperInstance?.forceUpdate();\n\n invokeHook('onMount', [instance]);\n\n if (instance.props.animation && getIsDefaultRenderFn()) {\n onTransitionedIn(duration, () => {\n instance.state.isShown = true;\n invokeHook('onShown', [instance]);\n });\n }\n };\n\n mount();\n }\n\n function hide(): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));\n }\n\n // Early bail-out\n const isAlreadyHidden = !instance.state.isVisible;\n const isDestroyed = instance.state.isDestroyed;\n const isDisabled = !instance.state.isEnabled;\n const duration = getValueAtIndexOrReturn(\n instance.props.duration,\n 1,\n defaultProps.duration\n );\n\n if (isAlreadyHidden || isDestroyed || isDisabled) {\n return;\n }\n\n invokeHook('onHide', [instance], false);\n if (instance.props.onHide(instance) === false) {\n return;\n }\n\n instance.state.isVisible = false;\n instance.state.isShown = false;\n ignoreOnFirstUpdate = false;\n isVisibleFromClick = false;\n\n if (getIsDefaultRenderFn()) {\n popper.style.visibility = 'hidden';\n }\n\n cleanupInteractiveMouseListeners();\n removeDocumentPress();\n handleStyles(true);\n\n if (getIsDefaultRenderFn()) {\n const {box, content} = getDefaultTemplateChildren();\n\n if (instance.props.animation) {\n setTransitionDuration([box, content], duration);\n setVisibilityState([box, content], 'hidden');\n }\n }\n\n handleAriaContentAttribute();\n handleAriaExpandedAttribute();\n\n if (instance.props.animation) {\n if (getIsDefaultRenderFn()) {\n onTransitionedOut(duration, instance.unmount);\n }\n } else {\n instance.unmount();\n }\n }\n\n function hideWithInteractivity(event: MouseEvent): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(\n instance.state.isDestroyed,\n createMemoryLeakWarning('hideWithInteractivity')\n );\n }\n\n getDocument().addEventListener('mousemove', debouncedOnMouseMove);\n pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);\n debouncedOnMouseMove(event);\n }\n\n function unmount(): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));\n }\n\n if (instance.state.isVisible) {\n instance.hide();\n }\n\n if (!instance.state.isMounted) {\n return;\n }\n\n destroyPopperInstance();\n\n // If a popper is not interactive, it will be appended outside the popper\n // tree by default. This seems mainly for interactive tippies, but we should\n // find a workaround if possible\n getNestedPopperTree().forEach((nestedPopper) => {\n nestedPopper._tippy!.unmount();\n });\n\n if (popper.parentNode) {\n popper.parentNode.removeChild(popper);\n }\n\n mountedInstances = mountedInstances.filter((i) => i !== instance);\n\n instance.state.isMounted = false;\n invokeHook('onHidden', [instance]);\n }\n\n function destroy(): void {\n /* istanbul ignore else */\n if (__DEV__) {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));\n }\n\n if (instance.state.isDestroyed) {\n return;\n }\n\n instance.clearDelayTimeouts();\n instance.unmount();\n\n removeListeners();\n\n delete reference._tippy;\n\n instance.state.isDestroyed = true;\n\n invokeHook('onDestroy', [instance]);\n }\n}\n", "import bindGlobalEventListeners, {\n currentInput,\n} from './bindGlobalEventListeners';\nimport createTippy, {mountedInstances} from './createTippy';\nimport {getArrayOfElements, isElement, isReferenceElement} from './dom-utils';\nimport {defaultProps, setDefaultProps, validateProps} from './props';\nimport {HideAll, HideAllOptions, Instance, Props, Targets} from './types';\nimport {validateTargets, warnWhen} from './validation';\n\nfunction tippy(\n targets: Targets,\n optionalProps: Partial = {}\n): Instance | Instance[] {\n const plugins = defaultProps.plugins.concat(optionalProps.plugins || []);\n\n /* istanbul ignore else */\n if (__DEV__) {\n validateTargets(targets);\n validateProps(optionalProps, plugins);\n }\n\n bindGlobalEventListeners();\n\n const passedProps: Partial = {...optionalProps, plugins};\n\n const elements = getArrayOfElements(targets);\n\n /* istanbul ignore else */\n if (__DEV__) {\n const isSingleContentElement = isElement(passedProps.content);\n const isMoreThanOneReferenceElement = elements.length > 1;\n warnWhen(\n isSingleContentElement && isMoreThanOneReferenceElement,\n [\n 'tippy() was passed an Element as the `content` prop, but more than',\n 'one tippy instance was created by this invocation. This means the',\n 'content element will only be appended to the last tippy instance.',\n '\\n\\n',\n 'Instead, pass the .innerHTML of the element, or use a function that',\n 'returns a cloned version of the element instead.',\n '\\n\\n',\n '1) content: element.innerHTML\\n',\n '2) content: () => element.cloneNode(true)',\n ].join(' ')\n );\n }\n\n const instances = elements.reduce(\n (acc, reference): Instance[] => {\n const instance = reference && createTippy(reference, passedProps);\n\n if (instance) {\n acc.push(instance);\n }\n\n return acc;\n },\n []\n );\n\n return isElement(targets) ? instances[0] : instances;\n}\n\ntippy.defaultProps = defaultProps;\ntippy.setDefaultProps = setDefaultProps;\ntippy.currentInput = currentInput;\n\nexport default tippy;\n\nexport const hideAll: HideAll = ({\n exclude: excludedReferenceOrInstance,\n duration,\n}: HideAllOptions = {}) => {\n mountedInstances.forEach((instance) => {\n let isExcluded = false;\n\n if (excludedReferenceOrInstance) {\n isExcluded = isReferenceElement(excludedReferenceOrInstance)\n ? instance.reference === excludedReferenceOrInstance\n : instance.popper === (excludedReferenceOrInstance as Instance).popper;\n }\n\n if (!isExcluded) {\n const originalDuration = instance.props.duration;\n\n instance.setProps({duration});\n instance.hide();\n\n if (!instance.state.isDestroyed) {\n instance.setProps({duration: originalDuration});\n }\n }\n });\n};\n", "import tippy from '..';\nimport {div} from '../dom-utils';\nimport {\n CreateSingleton,\n Plugin,\n CreateSingletonProps,\n ReferenceElement,\n CreateSingletonInstance,\n Instance,\n Props,\n} from '../types';\nimport {normalizeToArray, removeProperties} from '../utils';\nimport {errorWhen} from '../validation';\nimport {applyStyles, Modifier} from '@popperjs/core';\n\n// The default `applyStyles` modifier has a cleanup function that gets called\n// every time the popper is destroyed (i.e. a new target), removing the styles\n// and causing transitions to break for singletons when the console is open, but\n// most notably for non-transform styles being used, `gpuAcceleration: false`.\nconst applyStylesModifier: Modifier<'applyStyles', Record> = {\n ...applyStyles,\n effect({state}) {\n const initialStyles = {\n popper: {\n position: state.options.strategy,\n left: '0',\n top: '0',\n margin: '0',\n },\n arrow: {\n position: 'absolute',\n },\n reference: {},\n };\n\n Object.assign(state.elements.popper.style, initialStyles.popper);\n state.styles = initialStyles;\n\n if (state.elements.arrow) {\n Object.assign(state.elements.arrow.style, initialStyles.arrow);\n }\n\n // intentionally return no cleanup function\n // return () => { ... }\n },\n};\n\nconst createSingleton: CreateSingleton = (\n tippyInstances,\n optionalProps = {}\n) => {\n /* istanbul ignore else */\n if (__DEV__) {\n errorWhen(\n !Array.isArray(tippyInstances),\n [\n 'The first argument passed to createSingleton() must be an array of',\n 'tippy instances. The passed value was',\n String(tippyInstances),\n ].join(' ')\n );\n }\n\n let individualInstances = tippyInstances;\n let references: Array = [];\n let triggerTargets: Array = [];\n let currentTarget: Element | null;\n let overrides = optionalProps.overrides;\n let interceptSetPropsCleanups: Array<() => void> = [];\n let shownOnCreate = false;\n\n function setTriggerTargets(): void {\n triggerTargets = individualInstances\n .map((instance) =>\n normalizeToArray(instance.props.triggerTarget || instance.reference)\n )\n .reduce((acc, item) => acc.concat(item), []);\n }\n\n function setReferences(): void {\n references = individualInstances.map((instance) => instance.reference);\n }\n\n function enableInstances(isEnabled: boolean): void {\n individualInstances.forEach((instance) => {\n if (isEnabled) {\n instance.enable();\n } else {\n instance.disable();\n }\n });\n }\n\n function interceptSetProps(singleton: Instance): Array<() => void> {\n return individualInstances.map((instance) => {\n const originalSetProps = instance.setProps;\n\n instance.setProps = (props): void => {\n originalSetProps(props);\n\n if (instance.reference === currentTarget) {\n singleton.setProps(props);\n }\n };\n\n return (): void => {\n instance.setProps = originalSetProps;\n };\n });\n }\n\n // have to pass singleton, as it maybe undefined on first call\n function prepareInstance(\n singleton: Instance,\n target: ReferenceElement\n ): void {\n const index = triggerTargets.indexOf(target);\n\n // bail-out\n if (target === currentTarget) {\n return;\n }\n\n currentTarget = target;\n\n const overrideProps: Partial = (overrides || [])\n .concat('content')\n .reduce((acc, prop) => {\n (acc as any)[prop] = individualInstances[index].props[prop];\n return acc;\n }, {});\n\n singleton.setProps({\n ...overrideProps,\n getReferenceClientRect:\n typeof overrideProps.getReferenceClientRect === 'function'\n ? overrideProps.getReferenceClientRect\n : (): ClientRect => references[index]?.getBoundingClientRect(),\n });\n }\n\n enableInstances(false);\n setReferences();\n setTriggerTargets();\n\n const plugin: Plugin = {\n fn() {\n return {\n onDestroy(): void {\n enableInstances(true);\n },\n onHidden(): void {\n currentTarget = null;\n },\n onClickOutside(instance): void {\n if (instance.props.showOnCreate && !shownOnCreate) {\n shownOnCreate = true;\n currentTarget = null;\n }\n },\n onShow(instance): void {\n if (instance.props.showOnCreate && !shownOnCreate) {\n shownOnCreate = true;\n prepareInstance(instance, references[0]);\n }\n },\n onTrigger(instance, event): void {\n prepareInstance(instance, event.currentTarget as Element);\n },\n };\n },\n };\n\n const singleton = tippy(div(), {\n ...removeProperties(optionalProps, ['overrides']),\n plugins: [plugin, ...(optionalProps.plugins || [])],\n triggerTarget: triggerTargets,\n popperOptions: {\n ...optionalProps.popperOptions,\n modifiers: [\n ...(optionalProps.popperOptions?.modifiers || []),\n applyStylesModifier,\n ],\n },\n }) as CreateSingletonInstance;\n\n const originalShow = singleton.show;\n\n singleton.show = (target?: ReferenceElement | Instance | number): void => {\n originalShow();\n\n // first time, showOnCreate or programmatic call with no params\n // default to showing first instance\n if (!currentTarget && target == null) {\n return prepareInstance(singleton, references[0]);\n }\n\n // triggered from event (do nothing as prepareInstance already called by onTrigger)\n // programmatic call with no params when already visible (do nothing again)\n if (currentTarget && target == null) {\n return;\n }\n\n // target is index of instance\n if (typeof target === 'number') {\n return (\n references[target] && prepareInstance(singleton, references[target])\n );\n }\n\n // target is a child tippy instance\n if (individualInstances.indexOf(target as Instance) >= 0) {\n const ref = (target as Instance).reference;\n return prepareInstance(singleton, ref);\n }\n\n // target is a ReferenceElement\n if (references.indexOf(target as ReferenceElement) >= 0) {\n return prepareInstance(singleton, target as ReferenceElement);\n }\n };\n\n singleton.showNext = (): void => {\n const first = references[0];\n if (!currentTarget) {\n return singleton.show(0);\n }\n const index = references.indexOf(currentTarget);\n singleton.show(references[index + 1] || first);\n };\n\n singleton.showPrevious = (): void => {\n const last = references[references.length - 1];\n if (!currentTarget) {\n return singleton.show(last);\n }\n const index = references.indexOf(currentTarget);\n const target = references[index - 1] || last;\n singleton.show(target);\n };\n\n const originalSetProps = singleton.setProps;\n\n singleton.setProps = (props): void => {\n overrides = props.overrides || overrides;\n originalSetProps(props);\n };\n\n singleton.setInstances = (nextInstances): void => {\n enableInstances(true);\n interceptSetPropsCleanups.forEach((fn) => fn());\n\n individualInstances = nextInstances;\n\n enableInstances(false);\n setReferences();\n setTriggerTargets();\n interceptSetPropsCleanups = interceptSetProps(singleton);\n\n singleton.setProps({triggerTarget: triggerTargets});\n };\n\n interceptSetPropsCleanups = interceptSetProps(singleton);\n\n return singleton;\n};\n\nexport default createSingleton;\n", "import tippy from '..';\nimport {TOUCH_OPTIONS} from '../constants';\nimport {defaultProps} from '../props';\nimport {Instance, Props, Targets} from '../types';\nimport {ListenerObject} from '../types-internal';\nimport {normalizeToArray, removeProperties} from '../utils';\nimport {errorWhen} from '../validation';\n\nconst BUBBLING_EVENTS_MAP = {\n mouseover: 'mouseenter',\n focusin: 'focus',\n click: 'click',\n};\n\n/**\n * Creates a delegate instance that controls the creation of tippy instances\n * for child elements (`target` CSS selector).\n */\nfunction delegate(\n targets: Targets,\n props: Partial & {target: string}\n): Instance | Instance[] {\n /* istanbul ignore else */\n if (__DEV__) {\n errorWhen(\n !(props && props.target),\n [\n 'You must specity a `target` prop indicating a CSS selector string matching',\n 'the target elements that should receive a tippy.',\n ].join(' ')\n );\n }\n\n let listeners: ListenerObject[] = [];\n let childTippyInstances: Instance[] = [];\n let disabled = false;\n\n const {target} = props;\n\n const nativeProps = removeProperties(props, ['target']);\n const parentProps = {...nativeProps, trigger: 'manual', touch: false};\n const childProps = {\n touch: defaultProps.touch,\n ...nativeProps,\n showOnCreate: true,\n };\n\n const returnValue = tippy(targets, parentProps);\n const normalizedReturnValue = normalizeToArray(returnValue);\n\n function onTrigger(event: Event): void {\n if (!event.target || disabled) {\n return;\n }\n\n const targetNode = (event.target as Element).closest(target);\n\n if (!targetNode) {\n return;\n }\n\n // Get relevant trigger with fallbacks:\n // 1. Check `data-tippy-trigger` attribute on target node\n // 2. Fallback to `trigger` passed to `delegate()`\n // 3. Fallback to `defaultProps.trigger`\n const trigger =\n targetNode.getAttribute('data-tippy-trigger') ||\n props.trigger ||\n defaultProps.trigger;\n\n // @ts-ignore\n if (targetNode._tippy) {\n return;\n }\n\n if (event.type === 'touchstart' && typeof childProps.touch === 'boolean') {\n return;\n }\n\n if (\n event.type !== 'touchstart' &&\n trigger.indexOf((BUBBLING_EVENTS_MAP as any)[event.type]) < 0\n ) {\n return;\n }\n\n const instance = tippy(targetNode, childProps);\n\n if (instance) {\n childTippyInstances = childTippyInstances.concat(instance);\n }\n }\n\n function on(\n node: Element,\n eventType: string,\n handler: EventListener,\n options: boolean | Record = false\n ): void {\n node.addEventListener(eventType, handler, options);\n listeners.push({node, eventType, handler, options});\n }\n\n function addEventListeners(instance: Instance): void {\n const {reference} = instance;\n\n on(reference, 'touchstart', onTrigger, TOUCH_OPTIONS);\n on(reference, 'mouseover', onTrigger);\n on(reference, 'focusin', onTrigger);\n on(reference, 'click', onTrigger);\n }\n\n function removeEventListeners(): void {\n listeners.forEach(({node, eventType, handler, options}: ListenerObject) => {\n node.removeEventListener(eventType, handler, options);\n });\n listeners = [];\n }\n\n function applyMutations(instance: Instance): void {\n const originalDestroy = instance.destroy;\n const originalEnable = instance.enable;\n const originalDisable = instance.disable;\n\n instance.destroy = (shouldDestroyChildInstances = true): void => {\n if (shouldDestroyChildInstances) {\n childTippyInstances.forEach((instance) => {\n instance.destroy();\n });\n }\n\n childTippyInstances = [];\n\n removeEventListeners();\n originalDestroy();\n };\n\n instance.enable = (): void => {\n originalEnable();\n childTippyInstances.forEach((instance) => instance.enable());\n disabled = false;\n };\n\n instance.disable = (): void => {\n originalDisable();\n childTippyInstances.forEach((instance) => instance.disable());\n disabled = true;\n };\n\n addEventListeners(instance);\n }\n\n normalizedReturnValue.forEach(applyMutations);\n\n return returnValue;\n}\n\nexport default delegate;\n", "import {BACKDROP_CLASS} from '../constants';\nimport {div, setVisibilityState} from '../dom-utils';\nimport {getChildren} from '../template';\nimport {AnimateFill} from '../types';\nimport {errorWhen} from '../validation';\n\nconst animateFill: AnimateFill = {\n name: 'animateFill',\n defaultValue: false,\n fn(instance) {\n // @ts-ignore\n if (!instance.props.render?.$$tippy) {\n if (__DEV__) {\n errorWhen(\n instance.props.animateFill,\n 'The `animateFill` plugin requires the default render function.'\n );\n }\n\n return {};\n }\n\n const {box, content} = getChildren(instance.popper);\n\n const backdrop = instance.props.animateFill\n ? createBackdropElement()\n : null;\n\n return {\n onCreate(): void {\n if (backdrop) {\n box.insertBefore(backdrop, box.firstElementChild!);\n box.setAttribute('data-animatefill', '');\n box.style.overflow = 'hidden';\n\n instance.setProps({arrow: false, animation: 'shift-away'});\n }\n },\n onMount(): void {\n if (backdrop) {\n const {transitionDuration} = box.style;\n const duration = Number(transitionDuration.replace('ms', ''));\n\n // The content should fade in after the backdrop has mostly filled the\n // tooltip element. `clip-path` is the other alternative but is not\n // well-supported and is buggy on some devices.\n content.style.transitionDelay = `${Math.round(duration / 10)}ms`;\n\n backdrop.style.transitionDuration = transitionDuration;\n setVisibilityState([backdrop], 'visible');\n }\n },\n onShow(): void {\n if (backdrop) {\n backdrop.style.transitionDuration = '0ms';\n }\n },\n onHide(): void {\n if (backdrop) {\n setVisibilityState([backdrop], 'hidden');\n }\n },\n };\n },\n};\n\nexport default animateFill;\n\nfunction createBackdropElement(): HTMLDivElement {\n const backdrop = div();\n backdrop.className = BACKDROP_CLASS;\n setVisibilityState([backdrop], 'hidden');\n return backdrop;\n}\n", "import {getOwnerDocument, isMouseEvent} from '../dom-utils';\nimport {FollowCursor, Instance} from '../types';\n\nlet mouseCoords = {clientX: 0, clientY: 0};\nlet activeInstances: Array<{instance: Instance; doc: Document}> = [];\n\nfunction storeMouseCoords({clientX, clientY}: MouseEvent): void {\n mouseCoords = {clientX, clientY};\n}\n\nfunction addMouseCoordsListener(doc: Document): void {\n doc.addEventListener('mousemove', storeMouseCoords);\n}\n\nfunction removeMouseCoordsListener(doc: Document): void {\n doc.removeEventListener('mousemove', storeMouseCoords);\n}\n\nconst followCursor: FollowCursor = {\n name: 'followCursor',\n defaultValue: false,\n fn(instance) {\n const reference = instance.reference;\n const doc = getOwnerDocument(instance.props.triggerTarget || reference);\n\n let isInternalUpdate = false;\n let wasFocusEvent = false;\n let isUnmounted = true;\n let prevProps = instance.props;\n\n function getIsInitialBehavior(): boolean {\n return (\n instance.props.followCursor === 'initial' && instance.state.isVisible\n );\n }\n\n function addListener(): void {\n doc.addEventListener('mousemove', onMouseMove);\n }\n\n function removeListener(): void {\n doc.removeEventListener('mousemove', onMouseMove);\n }\n\n function unsetGetReferenceClientRect(): void {\n isInternalUpdate = true;\n instance.setProps({getReferenceClientRect: null});\n isInternalUpdate = false;\n }\n\n function onMouseMove(event: MouseEvent): void {\n // If the instance is interactive, avoid updating the position unless it's\n // over the reference element\n const isCursorOverReference = event.target\n ? reference.contains(event.target as Node)\n : true;\n const {followCursor} = instance.props;\n const {clientX, clientY} = event;\n\n const rect = reference.getBoundingClientRect();\n const relativeX = clientX - rect.left;\n const relativeY = clientY - rect.top;\n\n if (isCursorOverReference || !instance.props.interactive) {\n instance.setProps({\n // @ts-ignore - unneeded DOMRect properties\n getReferenceClientRect() {\n const rect = reference.getBoundingClientRect();\n\n let x = clientX;\n let y = clientY;\n\n if (followCursor === 'initial') {\n x = rect.left + relativeX;\n y = rect.top + relativeY;\n }\n\n const top = followCursor === 'horizontal' ? rect.top : y;\n const right = followCursor === 'vertical' ? rect.right : x;\n const bottom = followCursor === 'horizontal' ? rect.bottom : y;\n const left = followCursor === 'vertical' ? rect.left : x;\n\n return {\n width: right - left,\n height: bottom - top,\n top,\n right,\n bottom,\n left,\n };\n },\n });\n }\n }\n\n function create(): void {\n if (instance.props.followCursor) {\n activeInstances.push({instance, doc});\n addMouseCoordsListener(doc);\n }\n }\n\n function destroy(): void {\n activeInstances = activeInstances.filter(\n (data) => data.instance !== instance\n );\n\n if (activeInstances.filter((data) => data.doc === doc).length === 0) {\n removeMouseCoordsListener(doc);\n }\n }\n\n return {\n onCreate: create,\n onDestroy: destroy,\n onBeforeUpdate(): void {\n prevProps = instance.props;\n },\n onAfterUpdate(_, {followCursor}): void {\n if (isInternalUpdate) {\n return;\n }\n\n if (\n followCursor !== undefined &&\n prevProps.followCursor !== followCursor\n ) {\n destroy();\n\n if (followCursor) {\n create();\n\n if (\n instance.state.isMounted &&\n !wasFocusEvent &&\n !getIsInitialBehavior()\n ) {\n addListener();\n }\n } else {\n removeListener();\n unsetGetReferenceClientRect();\n }\n }\n },\n onMount(): void {\n if (instance.props.followCursor && !wasFocusEvent) {\n if (isUnmounted) {\n onMouseMove(mouseCoords as MouseEvent);\n isUnmounted = false;\n }\n\n if (!getIsInitialBehavior()) {\n addListener();\n }\n }\n },\n onTrigger(_, event): void {\n if (isMouseEvent(event)) {\n mouseCoords = {clientX: event.clientX, clientY: event.clientY};\n }\n wasFocusEvent = event.type === 'focus';\n },\n onHidden(): void {\n if (instance.props.followCursor) {\n unsetGetReferenceClientRect();\n removeListener();\n isUnmounted = true;\n }\n },\n };\n },\n};\n\nexport default followCursor;\n", "import {Modifier, Placement} from '@popperjs/core';\nimport {isMouseEvent} from '../dom-utils';\nimport {BasePlacement, InlinePositioning, Props} from '../types';\nimport {arrayFrom, getBasePlacement} from '../utils';\n\nfunction getProps(props: Props, modifier: Modifier): Partial {\n return {\n popperOptions: {\n ...props.popperOptions,\n modifiers: [\n ...(props.popperOptions?.modifiers || []).filter(\n ({name}) => name !== modifier.name\n ),\n modifier,\n ],\n },\n };\n}\n\nconst inlinePositioning: InlinePositioning = {\n name: 'inlinePositioning',\n defaultValue: false,\n fn(instance) {\n const {reference} = instance;\n\n function isEnabled(): boolean {\n return !!instance.props.inlinePositioning;\n }\n\n let placement: Placement;\n let cursorRectIndex = -1;\n let isInternalUpdate = false;\n let triedPlacements: Array = [];\n\n const modifier: Modifier<\n 'tippyInlinePositioning',\n Record\n > = {\n name: 'tippyInlinePositioning',\n enabled: true,\n phase: 'afterWrite',\n fn({state}) {\n if (isEnabled()) {\n if (triedPlacements.indexOf(state.placement) !== -1) {\n triedPlacements = [];\n }\n\n if (\n placement !== state.placement &&\n triedPlacements.indexOf(state.placement) === -1\n ) {\n triedPlacements.push(state.placement);\n instance.setProps({\n // @ts-ignore - unneeded DOMRect properties\n getReferenceClientRect: () =>\n getReferenceClientRect(state.placement),\n });\n }\n\n placement = state.placement;\n }\n },\n };\n\n function getReferenceClientRect(placement: Placement): Partial {\n return getInlineBoundingClientRect(\n getBasePlacement(placement),\n reference.getBoundingClientRect(),\n arrayFrom(reference.getClientRects()),\n cursorRectIndex\n );\n }\n\n function setInternalProps(partialProps: Partial): void {\n isInternalUpdate = true;\n instance.setProps(partialProps);\n isInternalUpdate = false;\n }\n\n function addModifier(): void {\n if (!isInternalUpdate) {\n setInternalProps(getProps(instance.props, modifier));\n }\n }\n\n return {\n onCreate: addModifier,\n onAfterUpdate: addModifier,\n onTrigger(_, event): void {\n if (isMouseEvent(event)) {\n const rects = arrayFrom(instance.reference.getClientRects());\n const cursorRect = rects.find(\n (rect) =>\n rect.left - 2 <= event.clientX &&\n rect.right + 2 >= event.clientX &&\n rect.top - 2 <= event.clientY &&\n rect.bottom + 2 >= event.clientY\n );\n const index = rects.indexOf(cursorRect);\n cursorRectIndex = index > -1 ? index : cursorRectIndex;\n }\n },\n onHidden(): void {\n cursorRectIndex = -1;\n },\n };\n },\n};\n\nexport default inlinePositioning;\n\nexport function getInlineBoundingClientRect(\n currentBasePlacement: BasePlacement | null,\n boundingRect: DOMRect,\n clientRects: DOMRect[],\n cursorRectIndex: number\n): {\n top: number;\n bottom: number;\n left: number;\n right: number;\n width: number;\n height: number;\n} {\n // Not an inline element, or placement is not yet known\n if (clientRects.length < 2 || currentBasePlacement === null) {\n return boundingRect;\n }\n\n // There are two rects and they are disjoined\n if (\n clientRects.length === 2 &&\n cursorRectIndex >= 0 &&\n clientRects[0].left > clientRects[1].right\n ) {\n return clientRects[cursorRectIndex] || boundingRect;\n }\n\n switch (currentBasePlacement) {\n case 'top':\n case 'bottom': {\n const firstRect = clientRects[0];\n const lastRect = clientRects[clientRects.length - 1];\n const isTop = currentBasePlacement === 'top';\n\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\n return {top, bottom, left, right, width, height};\n }\n case 'left':\n case 'right': {\n const minLeft = Math.min(...clientRects.map((rects) => rects.left));\n const maxRight = Math.max(...clientRects.map((rects) => rects.right));\n const measureRects = clientRects.filter((rect) =>\n currentBasePlacement === 'left'\n ? rect.left === minLeft\n : rect.right === maxRight\n );\n\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\n return {top, bottom, left, right, width, height};\n }\n default: {\n return boundingRect;\n }\n }\n}\n", "import {VirtualElement} from '@popperjs/core';\nimport {ReferenceElement, Sticky} from '../types';\n\nconst sticky: Sticky = {\n name: 'sticky',\n defaultValue: false,\n fn(instance) {\n const {reference, popper} = instance;\n\n function getReference(): ReferenceElement | VirtualElement {\n return instance.popperInstance\n ? instance.popperInstance.state.elements.reference\n : reference;\n }\n\n function shouldCheck(value: 'reference' | 'popper'): boolean {\n return instance.props.sticky === true || instance.props.sticky === value;\n }\n\n let prevRefRect: ClientRect | null = null;\n let prevPopRect: ClientRect | null = null;\n\n function updatePosition(): void {\n const currentRefRect = shouldCheck('reference')\n ? getReference().getBoundingClientRect()\n : null;\n const currentPopRect = shouldCheck('popper')\n ? popper.getBoundingClientRect()\n : null;\n\n if (\n (currentRefRect && areRectsDifferent(prevRefRect, currentRefRect)) ||\n (currentPopRect && areRectsDifferent(prevPopRect, currentPopRect))\n ) {\n if (instance.popperInstance) {\n instance.popperInstance.update();\n }\n }\n\n prevRefRect = currentRefRect;\n prevPopRect = currentPopRect;\n\n if (instance.state.isMounted) {\n requestAnimationFrame(updatePosition);\n }\n }\n\n return {\n onMount(): void {\n if (instance.props.sticky) {\n updatePosition();\n }\n },\n };\n },\n};\n\nexport default sticky;\n\nfunction areRectsDifferent(\n rectA: ClientRect | null,\n rectB: ClientRect | null\n): boolean {\n if (rectA && rectB) {\n return (\n rectA.top !== rectB.top ||\n rectA.right !== rectB.right ||\n rectA.bottom !== rectB.bottom ||\n rectA.left !== rectB.left\n );\n }\n\n return true;\n}\n", "import tippy from '../src';\nimport {render} from '../src/template';\n\ntippy.setDefaultProps({render});\n\nexport {default, hideAll} from '../src';\nexport {default as createSingleton} from '../src/addons/createSingleton';\nexport {default as delegate} from '../src/addons/delegate';\nexport {default as animateFill} from '../src/plugins/animateFill';\nexport {default as followCursor} from '../src/plugins/followCursor';\nexport {default as inlinePositioning} from '../src/plugins/inlinePositioning';\nexport {default as sticky} from '../src/plugins/sticky';\nexport {ROUND_ARROW as roundArrow} from '../src/constants';\n", "// https://github.com/fregante/text-field-edit/issues/16\nfunction safeTextInsert(text) {\n if (text === '') {\n return document.execCommand('delete');\n }\n return document.execCommand('insertText', false, text);\n}\nfunction insertTextFirefox(field, text) {\n // Found on https://www.everythingfrontend.com/posts/insert-text-into-textarea-at-cursor-position.html \uD83C\uDF88\n field.setRangeText(text, field.selectionStart || 0, field.selectionEnd || 0, 'end');\n field.dispatchEvent(new InputEvent('input', {\n data: text,\n inputType: 'insertText',\n }));\n}\n/** Inserts `text` at the cursor\u2019s position, replacing any selection, with **undo** support and by firing the `input` event. */\nexport function insert(field, text) {\n var document = field.ownerDocument;\n var initialFocus = document.activeElement;\n if (initialFocus !== field) {\n field.focus();\n }\n if (!safeTextInsert(text)) {\n insertTextFirefox(field, text);\n }\n if (initialFocus === document.body) {\n field.blur();\n }\n else if (initialFocus instanceof HTMLElement && initialFocus !== field) {\n initialFocus.focus();\n }\n}\n/** Replaces the entire content, equivalent to `field.value = text` but with **undo** support and by firing the `input` event. */\nexport function set(field, text) {\n field.select();\n insert(field, text);\n}\n/** Get the selected text in a field or an empty string if nothing is selected. */\nexport function getSelection(field) {\n return field.value.slice(field.selectionStart, field.selectionEnd);\n}\n/** Adds the `wrappingText` before and after field\u2019s selection (or cursor). If `endWrappingText` is provided, it will be used instead of `wrappingText` at on the right. */\nexport function wrapSelection(field, wrap, wrapEnd) {\n var selectionStart = field.selectionStart, selectionEnd = field.selectionEnd;\n var selection = getSelection(field);\n insert(field, wrap + selection + (wrapEnd !== null && wrapEnd !== void 0 ? wrapEnd : wrap));\n // Restore the selection around the previously-selected text\n field.selectionStart = selectionStart + wrap.length;\n field.selectionEnd = selectionEnd + wrap.length;\n}\n/** Finds and replaces strings and regex in the field\u2019s value, like `field.value = field.value.replace()` but better */\nexport function replace(field, searchValue, replacer, cursor) {\n if (cursor === void 0) { cursor = 'select'; }\n /** Remembers how much each match offset should be adjusted */\n var drift = 0;\n field.value.replace(searchValue, function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n // Select current match to replace it later\n var matchStart = drift + args[args.length - 2];\n var matchLength = args[0].length;\n field.selectionStart = matchStart;\n field.selectionEnd = matchStart + matchLength;\n var replacement = typeof replacer === 'string' ? replacer : replacer.apply(void 0, args);\n insert(field, replacement);\n if (cursor === 'select') {\n // Select replacement. Without this, the cursor would be after the replacement\n field.selectionStart = matchStart;\n }\n drift += replacement.length - matchLength;\n return replacement;\n });\n}\n", "import {\n VOID, PRIMITIVE,\n ARRAY, OBJECT,\n DATE, REGEXP, MAP, SET,\n ERROR, BIGINT\n} from './types.js';\n\nconst env = typeof self === 'object' ? self : globalThis;\n\nconst deserializer = ($, _) => {\n const as = (out, index) => {\n $.set(index, out);\n return out;\n };\n\n const unpair = index => {\n if ($.has(index))\n return $.get(index);\n\n const [type, value] = _[index];\n switch (type) {\n case PRIMITIVE:\n case VOID:\n return as(value, index);\n case ARRAY: {\n const arr = as([], index);\n for (const index of value)\n arr.push(unpair(index));\n return arr;\n }\n case OBJECT: {\n const object = as({}, index);\n for (const [key, index] of value)\n object[unpair(key)] = unpair(index);\n return object;\n }\n case DATE:\n return as(new Date(value), index);\n case REGEXP: {\n const {source, flags} = value;\n return as(new RegExp(source, flags), index);\n }\n case MAP: {\n const map = as(new Map, index);\n for (const [key, index] of value)\n map.set(unpair(key), unpair(index));\n return map;\n }\n case SET: {\n const set = as(new Set, index);\n for (const index of value)\n set.add(unpair(index));\n return set;\n }\n case ERROR: {\n const {name, message} = value;\n return as(new env[name](message), index);\n }\n case BIGINT:\n return as(BigInt(value), index);\n case 'BigInt':\n return as(Object(BigInt(value)), index);\n }\n return as(new env[type](value), index);\n };\n\n return unpair;\n};\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns a deserialized value from a serialized array of Records.\n * @param {Record[]} serialized a previously serialized value.\n * @returns {any}\n */\nexport const deserialize = serialized => deserializer(new Map, serialized)(0);\n", "import {\n VOID, PRIMITIVE,\n ARRAY, OBJECT,\n DATE, REGEXP, MAP, SET,\n ERROR, BIGINT\n} from './types.js';\n\nconst EMPTY = '';\n\nconst {toString} = {};\nconst {keys} = Object;\n\nconst typeOf = value => {\n const type = typeof value;\n if (type !== 'object' || !value)\n return [PRIMITIVE, type];\n\n const asString = toString.call(value).slice(8, -1);\n switch (asString) {\n case 'Array':\n return [ARRAY, EMPTY];\n case 'Object':\n return [OBJECT, EMPTY];\n case 'Date':\n return [DATE, EMPTY];\n case 'RegExp':\n return [REGEXP, EMPTY];\n case 'Map':\n return [MAP, EMPTY];\n case 'Set':\n return [SET, EMPTY];\n }\n\n if (asString.includes('Array'))\n return [ARRAY, asString];\n\n if (asString.includes('Error'))\n return [ERROR, asString];\n\n return [OBJECT, asString];\n};\n\nconst shouldSkip = ([TYPE, type]) => (\n TYPE === PRIMITIVE &&\n (type === 'function' || type === 'symbol')\n);\n\nconst serializer = (strict, json, $, _) => {\n\n const as = (out, value) => {\n const index = _.push(out) - 1;\n $.set(value, index);\n return index;\n };\n\n const pair = value => {\n if ($.has(value))\n return $.get(value);\n\n let [TYPE, type] = typeOf(value);\n switch (TYPE) {\n case PRIMITIVE: {\n let entry = value;\n switch (type) {\n case 'bigint':\n TYPE = BIGINT;\n entry = value.toString();\n break;\n case 'function':\n case 'symbol':\n if (strict)\n throw new TypeError('unable to serialize ' + type);\n entry = null;\n break;\n case 'undefined':\n return as([VOID], value);\n }\n return as([TYPE, entry], value);\n }\n case ARRAY: {\n if (type)\n return as([type, [...value]], value);\n \n const arr = [];\n const index = as([TYPE, arr], value);\n for (const entry of value)\n arr.push(pair(entry));\n return index;\n }\n case OBJECT: {\n if (type) {\n switch (type) {\n case 'BigInt':\n return as([type, value.toString()], value);\n case 'Boolean':\n case 'Number':\n case 'String':\n return as([type, value.valueOf()], value);\n }\n }\n\n if (json && ('toJSON' in value))\n return pair(value.toJSON());\n\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const key of keys(value)) {\n if (strict || !shouldSkip(typeOf(value[key])))\n entries.push([pair(key), pair(value[key])]);\n }\n return index;\n }\n case DATE:\n return as([TYPE, value.toISOString()], value);\n case REGEXP: {\n const {source, flags} = value;\n return as([TYPE, {source, flags}], value);\n }\n case MAP: {\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const [key, entry] of value) {\n if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))\n entries.push([pair(key), pair(entry)]);\n }\n return index;\n }\n case SET: {\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const entry of value) {\n if (strict || !shouldSkip(typeOf(entry)))\n entries.push(pair(entry));\n }\n return index;\n }\n }\n\n const {message} = value;\n return as([TYPE, {name: type, message}], value);\n };\n\n return pair;\n};\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns an array of serialized Records.\n * @param {any} value a serializable value.\n * @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,\n * if `true`, will not throw errors on incompatible types, and behave more\n * like JSON stringify would behave. Symbol and Function will be discarded.\n * @returns {Record[]}\n */\n export const serialize = (value, {json, lossy} = {}) => {\n const _ = [];\n return serializer(!(json || lossy), !!json, new Map, _)(value), _;\n};\n", "import {deserialize} from './deserialize.js';\nimport {serialize} from './serialize.js';\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns an array of serialized Records.\n * @param {any} any a serializable value.\n * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with\n * a transfer option (ignored when polyfilled) and/or non standard fields that\n * fallback to the polyfill if present.\n * @returns {Record[]}\n */\nexport default typeof structuredClone === \"function\" ?\n /* c8 ignore start */\n (any, options) => (\n options && ('json' in options || 'lossy' in options) ?\n deserialize(serialize(any, options)) : structuredClone(any)\n ) :\n (any, options) => deserialize(serialize(any, options));\n /* c8 ignore stop */\n\nexport {deserialize, serialize};\n", "/**\n * Throw a given error.\n *\n * @param {Error|null|undefined} [error]\n * Maybe error.\n * @returns {asserts error is null|undefined}\n */\nexport function bail(error) {\n if (error) {\n throw error\n }\n}\n", "export default function isPlainObject(value) {\n\tif (typeof value !== 'object' || value === null) {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);\n}\n", "/**\n * @typedef {(error?: Error|null|undefined, ...output: Array) => void} Callback\n * @typedef {(...input: Array) => any} Middleware\n *\n * @typedef {(...input: Array) => void} Run\n * Call all middleware.\n * @typedef {(fn: Middleware) => Pipeline} Use\n * Add `fn` (middleware) to the list.\n * @typedef {{run: Run, use: Use}} Pipeline\n * Middleware.\n */\n\n/**\n * Create new middleware.\n *\n * @returns {Pipeline}\n */\nexport function trough() {\n /** @type {Array} */\n const fns = []\n /** @type {Pipeline} */\n const pipeline = {run, use}\n\n return pipeline\n\n /** @type {Run} */\n function run(...values) {\n let middlewareIndex = -1\n /** @type {Callback} */\n const callback = values.pop()\n\n if (typeof callback !== 'function') {\n throw new TypeError('Expected function as last argument, not ' + callback)\n }\n\n next(null, ...values)\n\n /**\n * Run the next `fn`, or we\u2019re done.\n *\n * @param {Error|null|undefined} error\n * @param {Array} output\n */\n function next(error, ...output) {\n const fn = fns[++middlewareIndex]\n let index = -1\n\n if (error) {\n callback(error)\n return\n }\n\n // Copy non-nullish input into values.\n while (++index < values.length) {\n if (output[index] === null || output[index] === undefined) {\n output[index] = values[index]\n }\n }\n\n // Save the newly created `output` for the next call.\n values = output\n\n // Next or done.\n if (fn) {\n wrap(fn, next)(...output)\n } else {\n callback(null, ...output)\n }\n }\n }\n\n /** @type {Use} */\n function use(middelware) {\n if (typeof middelware !== 'function') {\n throw new TypeError(\n 'Expected `middelware` to be a function, not ' + middelware\n )\n }\n\n fns.push(middelware)\n return pipeline\n }\n}\n\n/**\n * Wrap `middleware`.\n * Can be sync or async; return a promise, receive a callback, or return new\n * values and errors.\n *\n * @param {Middleware} middleware\n * @param {Callback} callback\n */\nexport function wrap(middleware, callback) {\n /** @type {boolean} */\n let called\n\n return wrapped\n\n /**\n * Call `middleware`.\n * @this {any}\n * @param {Array} parameters\n * @returns {void}\n */\n function wrapped(...parameters) {\n const fnExpectsCallback = middleware.length > parameters.length\n /** @type {any} */\n let result\n\n if (fnExpectsCallback) {\n parameters.push(done)\n }\n\n try {\n result = middleware.apply(this, parameters)\n } catch (error) {\n const exception = /** @type {Error} */ (error)\n\n // Well, this is quite the pickle.\n // `middleware` received a callback and called it synchronously, but that\n // threw an error.\n // The only thing left to do is to throw the thing instead.\n if (fnExpectsCallback && called) {\n throw exception\n }\n\n return done(exception)\n }\n\n if (!fnExpectsCallback) {\n if (result instanceof Promise) {\n result.then(then, done)\n } else if (result instanceof Error) {\n done(result)\n } else {\n then(result)\n }\n }\n }\n\n /**\n * Call `callback`, only once.\n * @type {Callback}\n */\n function done(error, ...output) {\n if (!called) {\n called = true\n callback(error, ...output)\n }\n }\n\n /**\n * Call `done` with one value.\n *\n * @param {any} [value]\n */\n function then(value) {\n done(null, value)\n }\n}\n", "/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n */\n\n/**\n * @typedef NodeLike\n * @property {string} type\n * @property {PositionLike | null | undefined} [position]\n *\n * @typedef PointLike\n * @property {number | null | undefined} [line]\n * @property {number | null | undefined} [column]\n * @property {number | null | undefined} [offset]\n *\n * @typedef PositionLike\n * @property {PointLike | null | undefined} [start]\n * @property {PointLike | null | undefined} [end]\n */\n\n/**\n * Serialize the positional info of a point, position (start and end points),\n * or node.\n *\n * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value]\n * Node, position, or point.\n * @returns {string}\n * Pretty printed positional info of a node (`string`).\n *\n * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)\n * or a point `l:c` (when given `point`), where `l` stands for line, `c` for\n * column, `s` for `start`, and `e` for end.\n * An empty string (`''`) is returned if the given value is neither `node`,\n * `position`, nor `point`.\n */\nexport function stringifyPosition(value) {\n // Nothing.\n if (!value || typeof value !== 'object') {\n return ''\n }\n\n // Node.\n if ('position' in value || 'type' in value) {\n return position(value.position)\n }\n\n // Position.\n if ('start' in value || 'end' in value) {\n return position(value)\n }\n\n // Point.\n if ('line' in value || 'column' in value) {\n return point(value)\n }\n\n // ?\n return ''\n}\n\n/**\n * @param {Point | PointLike | null | undefined} point\n * @returns {string}\n */\nfunction point(point) {\n return index(point && point.line) + ':' + index(point && point.column)\n}\n\n/**\n * @param {Position | PositionLike | null | undefined} pos\n * @returns {string}\n */\nfunction position(pos) {\n return point(pos && pos.start) + '-' + point(pos && pos.end)\n}\n\n/**\n * @param {number | null | undefined} value\n * @returns {number}\n */\nfunction index(value) {\n return value && typeof value === 'number' ? value : 1\n}\n", "/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n */\n\n/**\n * @typedef {object & {type: string, position?: Position | undefined}} NodeLike\n *\n * @typedef Options\n * Configuration.\n * @property {Array | null | undefined} [ancestors]\n * Stack of (inclusive) ancestor nodes surrounding the message (optional).\n * @property {Error | null | undefined} [cause]\n * Original error cause of the message (optional).\n * @property {Point | Position | null | undefined} [place]\n * Place of message (optional).\n * @property {string | null | undefined} [ruleId]\n * Category of message (optional, example: `'my-rule'`).\n * @property {string | null | undefined} [source]\n * Namespace of who sent the message (optional, example: `'my-package'`).\n */\n\nimport {stringifyPosition} from 'unist-util-stringify-position'\n\n/**\n * Message.\n */\nexport class VFileMessage extends Error {\n /**\n * Create a message for `reason`.\n *\n * > \uD83E\uDEA6 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {Options | null | undefined} [options]\n * @returns\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns\n * Instance of `VFileMessage`.\n */\n // eslint-disable-next-line complexity\n constructor(causeOrReason, optionsOrParentOrPlace, origin) {\n super()\n\n if (typeof optionsOrParentOrPlace === 'string') {\n origin = optionsOrParentOrPlace\n optionsOrParentOrPlace = undefined\n }\n\n /** @type {string} */\n let reason = ''\n /** @type {Options} */\n let options = {}\n let legacyCause = false\n\n if (optionsOrParentOrPlace) {\n // Point.\n if (\n 'line' in optionsOrParentOrPlace &&\n 'column' in optionsOrParentOrPlace\n ) {\n options = {place: optionsOrParentOrPlace}\n }\n // Position.\n else if (\n 'start' in optionsOrParentOrPlace &&\n 'end' in optionsOrParentOrPlace\n ) {\n options = {place: optionsOrParentOrPlace}\n }\n // Node.\n else if ('type' in optionsOrParentOrPlace) {\n options = {\n ancestors: [optionsOrParentOrPlace],\n place: optionsOrParentOrPlace.position\n }\n }\n // Options.\n else {\n options = {...optionsOrParentOrPlace}\n }\n }\n\n if (typeof causeOrReason === 'string') {\n reason = causeOrReason\n }\n // Error.\n else if (!options.cause && causeOrReason) {\n legacyCause = true\n reason = causeOrReason.message\n options.cause = causeOrReason\n }\n\n if (!options.ruleId && !options.source && typeof origin === 'string') {\n const index = origin.indexOf(':')\n\n if (index === -1) {\n options.ruleId = origin\n } else {\n options.source = origin.slice(0, index)\n options.ruleId = origin.slice(index + 1)\n }\n }\n\n if (!options.place && options.ancestors && options.ancestors) {\n const parent = options.ancestors[options.ancestors.length - 1]\n\n if (parent) {\n options.place = parent.position\n }\n }\n\n const start =\n options.place && 'start' in options.place\n ? options.place.start\n : options.place\n\n /* eslint-disable no-unused-expressions */\n /**\n * Stack of ancestor nodes surrounding the message.\n *\n * @type {Array | undefined}\n */\n this.ancestors = options.ancestors || undefined\n\n /**\n * Original error cause of the message.\n *\n * @type {Error | undefined}\n */\n this.cause = options.cause || undefined\n\n /**\n * Starting column of message.\n *\n * @type {number | undefined}\n */\n this.column = start ? start.column : undefined\n\n /**\n * State of problem.\n *\n * * `true` \u2014 error, file not usable\n * * `false` \u2014 warning, change may be needed\n * * `undefined` \u2014 change likely not needed\n *\n * @type {boolean | null | undefined}\n */\n this.fatal = undefined\n\n /**\n * Path of a file (used throughout the `VFile` ecosystem).\n *\n * @type {string | undefined}\n */\n this.file\n\n // Field from `Error`.\n /**\n * Reason for message.\n *\n * @type {string}\n */\n this.message = reason\n\n /**\n * Starting line of error.\n *\n * @type {number | undefined}\n */\n this.line = start ? start.line : undefined\n\n // Field from `Error`.\n /**\n * Serialized positional info of message.\n *\n * On normal errors, this would be something like `ParseError`, buit in\n * `VFile` messages we use this space to show where an error happened.\n */\n this.name = stringifyPosition(options.place) || '1:1'\n\n /**\n * Place of message.\n *\n * @type {Point | Position | undefined}\n */\n this.place = options.place || undefined\n\n /**\n * Reason for message, should use markdown.\n *\n * @type {string}\n */\n this.reason = this.message\n\n /**\n * Category of message (example: `'my-rule'`).\n *\n * @type {string | undefined}\n */\n this.ruleId = options.ruleId || undefined\n\n /**\n * Namespace of message (example: `'my-package'`).\n *\n * @type {string | undefined}\n */\n this.source = options.source || undefined\n\n // Field from `Error`.\n /**\n * Stack of message.\n *\n * This is used by normal errors to show where something happened in\n * programming code, irrelevant for `VFile` messages,\n *\n * @type {string}\n */\n this.stack =\n legacyCause && options.cause && typeof options.cause.stack === 'string'\n ? options.cause.stack\n : ''\n\n // The following fields are \u201Cwell known\u201D.\n // Not standard.\n // Feel free to add other non-standard fields to your messages.\n\n /**\n * Specify the source value that\u2019s being reported, which is deemed\n * incorrect.\n *\n * @type {string | undefined}\n */\n this.actual\n\n /**\n * Suggest acceptable values that can be used instead of `actual`.\n *\n * @type {Array | undefined}\n */\n this.expected\n\n /**\n * Long form description of the message (you should use markdown).\n *\n * @type {string | undefined}\n */\n this.note\n\n /**\n * Link to docs for the message.\n *\n * > \uD83D\uDC49 **Note**: this must be an absolute URL that can be passed as `x`\n * > to `new URL(x)`.\n *\n * @type {string | undefined}\n */\n this.url\n /* eslint-enable no-unused-expressions */\n }\n}\n\nVFileMessage.prototype.file = ''\nVFileMessage.prototype.name = ''\nVFileMessage.prototype.reason = ''\nVFileMessage.prototype.message = ''\nVFileMessage.prototype.stack = ''\nVFileMessage.prototype.column = undefined\nVFileMessage.prototype.line = undefined\nVFileMessage.prototype.ancestors = undefined\nVFileMessage.prototype.cause = undefined\nVFileMessage.prototype.fatal = undefined\nVFileMessage.prototype.place = undefined\nVFileMessage.prototype.ruleId = undefined\nVFileMessage.prototype.source = undefined\n", "// A derivative work based on:\n// .\n// Which is licensed:\n//\n// MIT License\n//\n// Copyright (c) 2013 James Halliday\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of\n// this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to\n// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n// the Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A derivative work based on:\n//\n// Parts of that are extracted from Node\u2019s internal `path` module:\n// .\n// Which is licensed:\n//\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nexport const path = {basename, dirname, extname, join, sep: '/'}\n\n/* eslint-disable max-depth, complexity */\n\n/**\n * Get the basename from a path.\n *\n * @param {string} path\n * File path.\n * @param {string | null | undefined} [ext]\n * Extension to strip.\n * @returns {string}\n * Stem or basename.\n */\nfunction basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') {\n throw new TypeError('\"ext\" argument must be a string')\n }\n\n assertPath(path)\n let start = 0\n let end = -1\n let index = path.length\n /** @type {boolean | undefined} */\n let seenNonSlash\n\n if (ext === undefined || ext.length === 0 || ext.length > path.length) {\n while (index--) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (seenNonSlash) {\n start = index + 1\n break\n }\n } else if (end < 0) {\n // We saw the first non-path separator, mark this as the end of our\n // path component.\n seenNonSlash = true\n end = index + 1\n }\n }\n\n return end < 0 ? '' : path.slice(start, end)\n }\n\n if (ext === path) {\n return ''\n }\n\n let firstNonSlashEnd = -1\n let extIndex = ext.length - 1\n\n while (index--) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (seenNonSlash) {\n start = index + 1\n break\n }\n } else {\n if (firstNonSlashEnd < 0) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching.\n seenNonSlash = true\n firstNonSlashEnd = index + 1\n }\n\n if (extIndex > -1) {\n // Try to match the explicit extension.\n if (path.codePointAt(index) === ext.codePointAt(extIndex--)) {\n if (extIndex < 0) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = index\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIndex = -1\n end = firstNonSlashEnd\n }\n }\n }\n }\n\n if (start === end) {\n end = firstNonSlashEnd\n } else if (end < 0) {\n end = path.length\n }\n\n return path.slice(start, end)\n}\n\n/**\n * Get the dirname from a path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * File path.\n */\nfunction dirname(path) {\n assertPath(path)\n\n if (path.length === 0) {\n return '.'\n }\n\n let end = -1\n let index = path.length\n /** @type {boolean | undefined} */\n let unmatchedSlash\n\n // Prefix `--` is important to not run on `0`.\n while (--index) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n if (unmatchedSlash) {\n end = index\n break\n }\n } else if (!unmatchedSlash) {\n // We saw the first non-path separator\n unmatchedSlash = true\n }\n }\n\n return end < 0\n ? path.codePointAt(0) === 47 /* `/` */\n ? '/'\n : '.'\n : end === 1 && path.codePointAt(0) === 47 /* `/` */\n ? '//'\n : path.slice(0, end)\n}\n\n/**\n * Get an extname from a path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * Extname.\n */\nfunction extname(path) {\n assertPath(path)\n\n let index = path.length\n\n let end = -1\n let startPart = 0\n let startDot = -1\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find.\n let preDotState = 0\n /** @type {boolean | undefined} */\n let unmatchedSlash\n\n while (index--) {\n const code = path.codePointAt(index)\n\n if (code === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (unmatchedSlash) {\n startPart = index + 1\n break\n }\n\n continue\n }\n\n if (end < 0) {\n // We saw the first non-path separator, mark this as the end of our\n // extension.\n unmatchedSlash = true\n end = index + 1\n }\n\n if (code === 46 /* `.` */) {\n // If this is our first dot, mark it as the start of our extension.\n if (startDot < 0) {\n startDot = index\n } else if (preDotState !== 1) {\n preDotState = 1\n }\n } else if (startDot > -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension.\n preDotState = -1\n }\n }\n\n if (\n startDot < 0 ||\n end < 0 ||\n // We saw a non-dot character immediately before the dot.\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly `..`.\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n ) {\n return ''\n }\n\n return path.slice(startDot, end)\n}\n\n/**\n * Join segments from a path.\n *\n * @param {Array} segments\n * Path segments.\n * @returns {string}\n * File path.\n */\nfunction join(...segments) {\n let index = -1\n /** @type {string | undefined} */\n let joined\n\n while (++index < segments.length) {\n assertPath(segments[index])\n\n if (segments[index]) {\n joined =\n joined === undefined ? segments[index] : joined + '/' + segments[index]\n }\n }\n\n return joined === undefined ? '.' : normalize(joined)\n}\n\n/**\n * Normalize a basic file path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * File path.\n */\n// Note: `normalize` is not exposed as `path.normalize`, so some code is\n// manually removed from it.\nfunction normalize(path) {\n assertPath(path)\n\n const absolute = path.codePointAt(0) === 47 /* `/` */\n\n // Normalize the path according to POSIX rules.\n let value = normalizeString(path, !absolute)\n\n if (value.length === 0 && !absolute) {\n value = '.'\n }\n\n if (value.length > 0 && path.codePointAt(path.length - 1) === 47 /* / */) {\n value += '/'\n }\n\n return absolute ? '/' + value : value\n}\n\n/**\n * Resolve `.` and `..` elements in a path with directory names.\n *\n * @param {string} path\n * File path.\n * @param {boolean} allowAboveRoot\n * Whether `..` can move above root.\n * @returns {string}\n * File path.\n */\nfunction normalizeString(path, allowAboveRoot) {\n let result = ''\n let lastSegmentLength = 0\n let lastSlash = -1\n let dots = 0\n let index = -1\n /** @type {number | undefined} */\n let code\n /** @type {number} */\n let lastSlashIndex\n\n while (++index <= path.length) {\n if (index < path.length) {\n code = path.codePointAt(index)\n } else if (code === 47 /* `/` */) {\n break\n } else {\n code = 47 /* `/` */\n }\n\n if (code === 47 /* `/` */) {\n if (lastSlash === index - 1 || dots === 1) {\n // Empty.\n } else if (lastSlash !== index - 1 && dots === 2) {\n if (\n result.length < 2 ||\n lastSegmentLength !== 2 ||\n result.codePointAt(result.length - 1) !== 46 /* `.` */ ||\n result.codePointAt(result.length - 2) !== 46 /* `.` */\n ) {\n if (result.length > 2) {\n lastSlashIndex = result.lastIndexOf('/')\n\n if (lastSlashIndex !== result.length - 1) {\n if (lastSlashIndex < 0) {\n result = ''\n lastSegmentLength = 0\n } else {\n result = result.slice(0, lastSlashIndex)\n lastSegmentLength = result.length - 1 - result.lastIndexOf('/')\n }\n\n lastSlash = index\n dots = 0\n continue\n }\n } else if (result.length > 0) {\n result = ''\n lastSegmentLength = 0\n lastSlash = index\n dots = 0\n continue\n }\n }\n\n if (allowAboveRoot) {\n result = result.length > 0 ? result + '/..' : '..'\n lastSegmentLength = 2\n }\n } else {\n if (result.length > 0) {\n result += '/' + path.slice(lastSlash + 1, index)\n } else {\n result = path.slice(lastSlash + 1, index)\n }\n\n lastSegmentLength = index - lastSlash - 1\n }\n\n lastSlash = index\n dots = 0\n } else if (code === 46 /* `.` */ && dots > -1) {\n dots++\n } else {\n dots = -1\n }\n }\n\n return result\n}\n\n/**\n * Make sure `path` is a string.\n *\n * @param {string} path\n * File path.\n * @returns {asserts path is string}\n * Nothing.\n */\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError(\n 'Path must be a string. Received ' + JSON.stringify(path)\n )\n }\n}\n\n/* eslint-enable max-depth, complexity */\n", "// Somewhat based on:\n// .\n// But I don\u2019t think one tiny line of code can be copyrighted. \uD83D\uDE05\nexport const proc = {cwd}\n\nfunction cwd() {\n return '/'\n}\n", "/**\n * Checks if a value has the shape of a WHATWG URL object.\n *\n * Using a symbol or instanceof would not be able to recognize URL objects\n * coming from other implementations (e.g. in Electron), so instead we are\n * checking some well known properties for a lack of a better test.\n *\n * We use `href` and `protocol` as they are the only properties that are\n * easy to retrieve and calculate due to the lazy nature of the getters.\n *\n * We check for auth attribute to distinguish legacy url instance with\n * WHATWG URL instance.\n *\n * @param {unknown} fileUrlOrPath\n * File path or URL.\n * @returns {fileUrlOrPath is URL}\n * Whether it\u2019s a URL.\n */\n// From: \nexport function isUrl(fileUrlOrPath) {\n return Boolean(\n fileUrlOrPath !== null &&\n typeof fileUrlOrPath === 'object' &&\n 'href' in fileUrlOrPath &&\n fileUrlOrPath.href &&\n 'protocol' in fileUrlOrPath &&\n fileUrlOrPath.protocol &&\n // @ts-expect-error: indexing is fine.\n fileUrlOrPath.auth === undefined\n )\n}\n", "import {isUrl} from './minurl.shared.js'\n\nexport {isUrl} from './minurl.shared.js'\n\n// See: \n\n/**\n * @param {URL | string} path\n * File URL.\n * @returns {string}\n * File URL.\n */\nexport function urlToPath(path) {\n if (typeof path === 'string') {\n path = new URL(path)\n } else if (!isUrl(path)) {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'The \"path\" argument must be of type string or an instance of URL. Received `' +\n path +\n '`'\n )\n error.code = 'ERR_INVALID_ARG_TYPE'\n throw error\n }\n\n if (path.protocol !== 'file:') {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError('The URL must be of scheme file')\n error.code = 'ERR_INVALID_URL_SCHEME'\n throw error\n }\n\n return getPathFromURLPosix(path)\n}\n\n/**\n * Get a path from a POSIX URL.\n *\n * @param {URL} url\n * URL.\n * @returns {string}\n * File path.\n */\nfunction getPathFromURLPosix(url) {\n if (url.hostname !== '') {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'File URL host must be \"localhost\" or empty on darwin'\n )\n error.code = 'ERR_INVALID_FILE_URL_HOST'\n throw error\n }\n\n const pathname = url.pathname\n let index = -1\n\n while (++index < pathname.length) {\n if (\n pathname.codePointAt(index) === 37 /* `%` */ &&\n pathname.codePointAt(index + 1) === 50 /* `2` */\n ) {\n const third = pathname.codePointAt(index + 2)\n if (third === 70 /* `F` */ || third === 102 /* `f` */) {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'File URL path must not include encoded / characters'\n )\n error.code = 'ERR_INVALID_FILE_URL_PATH'\n throw error\n }\n }\n }\n\n return decodeURIComponent(pathname)\n}\n", "/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n * @typedef {import('vfile-message').Options} MessageOptions\n * @typedef {import('../index.js').Data} Data\n * @typedef {import('../index.js').Value} Value\n */\n\n/**\n * @typedef {object & {type: string, position?: Position | undefined}} NodeLike\n *\n * @typedef {Options | URL | VFile | Value} Compatible\n * Things that can be passed to the constructor.\n *\n * @typedef VFileCoreOptions\n * Set multiple values.\n * @property {string | null | undefined} [basename]\n * Set `basename` (name).\n * @property {string | null | undefined} [cwd]\n * Set `cwd` (working directory).\n * @property {Data | null | undefined} [data]\n * Set `data` (associated info).\n * @property {string | null | undefined} [dirname]\n * Set `dirname` (path w/o basename).\n * @property {string | null | undefined} [extname]\n * Set `extname` (extension with dot).\n * @property {Array | null | undefined} [history]\n * Set `history` (paths the file moved between).\n * @property {URL | string | null | undefined} [path]\n * Set `path` (current path).\n * @property {string | null | undefined} [stem]\n * Set `stem` (name without extension).\n * @property {Value | null | undefined} [value]\n * Set `value` (the contents of the file).\n *\n * @typedef Map\n * Raw source map.\n *\n * See:\n * .\n * @property {number} version\n * Which version of the source map spec this map is following.\n * @property {Array} sources\n * An array of URLs to the original source files.\n * @property {Array} names\n * An array of identifiers which can be referenced by individual mappings.\n * @property {string | undefined} [sourceRoot]\n * The URL root from which all sources are relative.\n * @property {Array | undefined} [sourcesContent]\n * An array of contents of the original source files.\n * @property {string} mappings\n * A string of base64 VLQs which contain the actual mappings.\n * @property {string} file\n * The generated file this source map is associated with.\n *\n * @typedef {Record & VFileCoreOptions} Options\n * Configuration.\n *\n * A bunch of keys that will be shallow copied over to the new file.\n *\n * @typedef {Record} ReporterSettings\n * Configuration for reporters.\n */\n\n/**\n * @template [Settings=ReporterSettings]\n * Options type.\n * @callback Reporter\n * Type for a reporter.\n * @param {Array} files\n * Files to report.\n * @param {Settings} options\n * Configuration.\n * @returns {string}\n * Report.\n */\n\nimport {VFileMessage} from 'vfile-message'\nimport {path} from 'vfile/do-not-use-conditional-minpath'\nimport {proc} from 'vfile/do-not-use-conditional-minproc'\nimport {urlToPath, isUrl} from 'vfile/do-not-use-conditional-minurl'\n\n/**\n * Order of setting (least specific to most), we need this because otherwise\n * `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a\n * stem can be set.\n */\nconst order = /** @type {const} */ ([\n 'history',\n 'path',\n 'basename',\n 'stem',\n 'extname',\n 'dirname'\n])\n\nexport class VFile {\n /**\n * Create a new virtual file.\n *\n * `options` is treated as:\n *\n * * `string` or `Uint8Array` \u2014 `{value: options}`\n * * `URL` \u2014 `{path: options}`\n * * `VFile` \u2014 shallow copies its data over to the new file\n * * `object` \u2014 all fields are shallow copied over to the new file\n *\n * Path related fields are set in the following order (least specific to\n * most specific): `history`, `path`, `basename`, `stem`, `extname`,\n * `dirname`.\n *\n * You cannot set `dirname` or `extname` without setting either `history`,\n * `path`, `basename`, or `stem` too.\n *\n * @param {Compatible | null | undefined} [value]\n * File value.\n * @returns\n * New instance.\n */\n constructor(value) {\n /** @type {Options | VFile} */\n let options\n\n if (!value) {\n options = {}\n } else if (isUrl(value)) {\n options = {path: value}\n } else if (typeof value === 'string' || isUint8Array(value)) {\n options = {value}\n } else {\n options = value\n }\n\n /* eslint-disable no-unused-expressions */\n\n /**\n * Base of `path` (default: `process.cwd()` or `'/'` in browsers).\n *\n * @type {string}\n */\n this.cwd = proc.cwd()\n\n /**\n * Place to store custom info (default: `{}`).\n *\n * It\u2019s OK to store custom data directly on the file but moving it to\n * `data` is recommended.\n *\n * @type {Data}\n */\n this.data = {}\n\n /**\n * List of file paths the file moved between.\n *\n * The first is the original path and the last is the current path.\n *\n * @type {Array}\n */\n this.history = []\n\n /**\n * List of messages associated with the file.\n *\n * @type {Array}\n */\n this.messages = []\n\n /**\n * Raw value.\n *\n * @type {Value}\n */\n this.value\n\n // The below are non-standard, they are \u201Cwell-known\u201D.\n // As in, used in several tools.\n /**\n * Source map.\n *\n * This type is equivalent to the `RawSourceMap` type from the `source-map`\n * module.\n *\n * @type {Map | null | undefined}\n */\n this.map\n\n /**\n * Custom, non-string, compiled, representation.\n *\n * This is used by unified to store non-string results.\n * One example is when turning markdown into React nodes.\n *\n * @type {unknown}\n */\n this.result\n\n /**\n * Whether a file was saved to disk.\n *\n * This is used by vfile reporters.\n *\n * @type {boolean}\n */\n this.stored\n /* eslint-enable no-unused-expressions */\n\n // Set path related properties in the correct order.\n let index = -1\n\n while (++index < order.length) {\n const prop = order[index]\n\n // Note: we specifically use `in` instead of `hasOwnProperty` to accept\n // `vfile`s too.\n if (\n prop in options &&\n options[prop] !== undefined &&\n options[prop] !== null\n ) {\n // @ts-expect-error: TS doesn\u2019t understand basic reality.\n this[prop] = prop === 'history' ? [...options[prop]] : options[prop]\n }\n }\n\n /** @type {string} */\n let prop\n\n // Set non-path related properties.\n for (prop in options) {\n // @ts-expect-error: fine to set other things.\n if (!order.includes(prop)) {\n // @ts-expect-error: fine to set other things.\n this[prop] = options[prop]\n }\n }\n }\n\n /**\n * Get the basename (including extname) (example: `'index.min.js'`).\n *\n * @returns {string | undefined}\n * Basename.\n */\n get basename() {\n return typeof this.path === 'string' ? path.basename(this.path) : undefined\n }\n\n /**\n * Set basename (including extname) (`'index.min.js'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be nullified (use `file.path = file.dirname` instead).\n *\n * @param {string} basename\n * Basename.\n * @returns {undefined}\n * Nothing.\n */\n set basename(basename) {\n assertNonEmpty(basename, 'basename')\n assertPart(basename, 'basename')\n this.path = path.join(this.dirname || '', basename)\n }\n\n /**\n * Get the parent path (example: `'~'`).\n *\n * @returns {string | undefined}\n * Dirname.\n */\n get dirname() {\n return typeof this.path === 'string' ? path.dirname(this.path) : undefined\n }\n\n /**\n * Set the parent path (example: `'~'`).\n *\n * Cannot be set if there\u2019s no `path` yet.\n *\n * @param {string | undefined} dirname\n * Dirname.\n * @returns {undefined}\n * Nothing.\n */\n set dirname(dirname) {\n assertPath(this.basename, 'dirname')\n this.path = path.join(dirname || '', this.basename)\n }\n\n /**\n * Get the extname (including dot) (example: `'.js'`).\n *\n * @returns {string | undefined}\n * Extname.\n */\n get extname() {\n return typeof this.path === 'string' ? path.extname(this.path) : undefined\n }\n\n /**\n * Set the extname (including dot) (example: `'.js'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be set if there\u2019s no `path` yet.\n *\n * @param {string | undefined} extname\n * Extname.\n * @returns {undefined}\n * Nothing.\n */\n set extname(extname) {\n assertPart(extname, 'extname')\n assertPath(this.dirname, 'extname')\n\n if (extname) {\n if (extname.codePointAt(0) !== 46 /* `.` */) {\n throw new Error('`extname` must start with `.`')\n }\n\n if (extname.includes('.', 1)) {\n throw new Error('`extname` cannot contain multiple dots')\n }\n }\n\n this.path = path.join(this.dirname, this.stem + (extname || ''))\n }\n\n /**\n * Get the full path (example: `'~/index.min.js'`).\n *\n * @returns {string}\n * Path.\n */\n get path() {\n return this.history[this.history.length - 1]\n }\n\n /**\n * Set the full path (example: `'~/index.min.js'`).\n *\n * Cannot be nullified.\n * You can set a file URL (a `URL` object with a `file:` protocol) which will\n * be turned into a path with `url.fileURLToPath`.\n *\n * @param {URL | string} path\n * Path.\n * @returns {undefined}\n * Nothing.\n */\n set path(path) {\n if (isUrl(path)) {\n path = urlToPath(path)\n }\n\n assertNonEmpty(path, 'path')\n\n if (this.path !== path) {\n this.history.push(path)\n }\n }\n\n /**\n * Get the stem (basename w/o extname) (example: `'index.min'`).\n *\n * @returns {string | undefined}\n * Stem.\n */\n get stem() {\n return typeof this.path === 'string'\n ? path.basename(this.path, this.extname)\n : undefined\n }\n\n /**\n * Set the stem (basename w/o extname) (example: `'index.min'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be nullified (use `file.path = file.dirname` instead).\n *\n * @param {string} stem\n * Stem.\n * @returns {undefined}\n * Nothing.\n */\n set stem(stem) {\n assertNonEmpty(stem, 'stem')\n assertPart(stem, 'stem')\n this.path = path.join(this.dirname || '', stem + (this.extname || ''))\n }\n\n // Normal prototypal methods.\n /**\n * Create a fatal message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `true` (error; file not usable)\n * and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > \uD83E\uDEA6 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {never}\n * Never.\n * @throws {VFileMessage}\n * Message.\n */\n fail(causeOrReason, optionsOrParentOrPlace, origin) {\n // @ts-expect-error: the overloads are fine.\n const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)\n\n message.fatal = true\n\n throw message\n }\n\n /**\n * Create an info message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `undefined` (info; change\n * likely not needed) and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > \uD83E\uDEA6 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {VFileMessage}\n * Message.\n */\n info(causeOrReason, optionsOrParentOrPlace, origin) {\n // @ts-expect-error: the overloads are fine.\n const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)\n\n message.fatal = undefined\n\n return message\n }\n\n /**\n * Create a message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `false` (warning; change may be\n * needed) and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > \uD83E\uDEA6 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {VFileMessage}\n * Message.\n */\n message(causeOrReason, optionsOrParentOrPlace, origin) {\n const message = new VFileMessage(\n // @ts-expect-error: the overloads are fine.\n causeOrReason,\n optionsOrParentOrPlace,\n origin\n )\n\n if (this.path) {\n message.name = this.path + ':' + message.name\n message.file = this.path\n }\n\n message.fatal = false\n\n this.messages.push(message)\n\n return message\n }\n\n /**\n * Serialize the file.\n *\n * > **Note**: which encodings are supported depends on the engine.\n * > For info on Node.js, see:\n * > .\n *\n * @param {string | null | undefined} [encoding='utf8']\n * Character encoding to understand `value` as when it\u2019s a `Uint8Array`\n * (default: `'utf-8'`).\n * @returns {string}\n * Serialized file.\n */\n toString(encoding) {\n if (this.value === undefined) {\n return ''\n }\n\n if (typeof this.value === 'string') {\n return this.value\n }\n\n const decoder = new TextDecoder(encoding || undefined)\n return decoder.decode(this.value)\n }\n}\n\n/**\n * Assert that `part` is not a path (as in, does not contain `path.sep`).\n *\n * @param {string | null | undefined} part\n * File path part.\n * @param {string} name\n * Part name.\n * @returns {undefined}\n * Nothing.\n */\nfunction assertPart(part, name) {\n if (part && part.includes(path.sep)) {\n throw new Error(\n '`' + name + '` cannot be a path: did not expect `' + path.sep + '`'\n )\n }\n}\n\n/**\n * Assert that `part` is not empty.\n *\n * @param {string | undefined} part\n * Thing.\n * @param {string} name\n * Part name.\n * @returns {asserts part is string}\n * Nothing.\n */\nfunction assertNonEmpty(part, name) {\n if (!part) {\n throw new Error('`' + name + '` cannot be empty')\n }\n}\n\n/**\n * Assert `path` exists.\n *\n * @param {string | undefined} path\n * Path.\n * @param {string} name\n * Dependency name.\n * @returns {asserts path is string}\n * Nothing.\n */\nfunction assertPath(path, name) {\n if (!path) {\n throw new Error('Setting `' + name + '` requires `path` to be set too')\n }\n}\n\n/**\n * Assert `value` is an `Uint8Array`.\n *\n * @param {unknown} value\n * thing.\n * @returns {value is Uint8Array}\n * Whether `value` is an `Uint8Array`.\n */\nfunction isUint8Array(value) {\n return Boolean(\n value &&\n typeof value === 'object' &&\n 'byteLength' in value &&\n 'byteOffset' in value\n )\n}\n", "export const CallableInstance =\n /**\n * @type {new , Result>(property: string | symbol) => (...parameters: Parameters) => Result}\n */\n (\n /** @type {unknown} */\n (\n /**\n * @this {Function}\n * @param {string | symbol} property\n * @returns {(...parameters: Array) => unknown}\n */\n function (property) {\n const self = this\n const constr = self.constructor\n const proto = /** @type {Record} */ (\n // Prototypes do exist.\n // type-coverage:ignore-next-line\n constr.prototype\n )\n const func = proto[property]\n /** @type {(...parameters: Array) => unknown} */\n const apply = function () {\n return func.apply(apply, arguments)\n }\n\n Object.setPrototypeOf(apply, proto)\n\n const names = Object.getOwnPropertyNames(func)\n\n for (const p of names) {\n const descriptor = Object.getOwnPropertyDescriptor(func, p)\n if (descriptor) Object.defineProperty(apply, p, descriptor)\n }\n\n return apply\n }\n )\n )\n", "/**\n * @typedef {import('trough').Pipeline} Pipeline\n *\n * @typedef {import('unist').Node} Node\n *\n * @typedef {import('vfile').Compatible} Compatible\n * @typedef {import('vfile').Value} Value\n *\n * @typedef {import('../index.js').CompileResultMap} CompileResultMap\n * @typedef {import('../index.js').Data} Data\n * @typedef {import('../index.js').Settings} Settings\n */\n\n/**\n * @typedef {CompileResultMap[keyof CompileResultMap]} CompileResults\n * Acceptable results from compilers.\n *\n * To register custom results, add them to\n * {@link CompileResultMap `CompileResultMap`}.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The node that the compiler receives (default: `Node`).\n * @template {CompileResults} [Result=CompileResults]\n * The thing that the compiler yields (default: `CompileResults`).\n * @callback Compiler\n * A **compiler** handles the compiling of a syntax tree to something else\n * (in most cases, text) (TypeScript type).\n *\n * It is used in the stringify phase and called with a {@link Node `Node`}\n * and {@link VFile `VFile`} representation of the document to compile.\n * It should return the textual representation of the given tree (typically\n * `string`).\n *\n * > \uD83D\uDC49 **Note**: unified typically compiles by serializing: most compilers\n * > return `string` (or `Uint8Array`).\n * > Some compilers, such as the one configured with\n * > [`rehype-react`][rehype-react], return other values (in this case, a\n * > React tree).\n * > If you\u2019re using a compiler that doesn\u2019t serialize, expect different\n * > result values.\n * >\n * > To register custom results in TypeScript, add them to\n * > {@link CompileResultMap `CompileResultMap`}.\n *\n * [rehype-react]: https://github.com/rehypejs/rehype-react\n * @param {Tree} tree\n * Tree to compile.\n * @param {VFile} file\n * File associated with `tree`.\n * @returns {Result}\n * New content: compiled text (`string` or `Uint8Array`, for `file.value`) or\n * something else (for `file.result`).\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The node that the parser yields (default: `Node`)\n * @callback Parser\n * A **parser** handles the parsing of text to a syntax tree.\n *\n * It is used in the parse phase and is called with a `string` and\n * {@link VFile `VFile`} of the document to parse.\n * It must return the syntax tree representation of the given file\n * ({@link Node `Node`}).\n * @param {string} document\n * Document to parse.\n * @param {VFile} file\n * File associated with `document`.\n * @returns {Tree}\n * Node representing the given file.\n */\n\n/**\n * @typedef {(\n * Plugin, any, any> |\n * PluginTuple, any, any> |\n * Preset\n * )} Pluggable\n * Union of the different ways to add plugins and settings.\n */\n\n/**\n * @typedef {Array} PluggableList\n * List of plugins and presets.\n */\n\n// Note: we can\u2019t use `callback` yet as it messes up `this`:\n// .\n/**\n * @template {Array} [PluginParameters=[]]\n * Arguments passed to the plugin (default: `[]`, the empty tuple).\n * @template {Node | string | undefined} [Input=Node]\n * Value that is expected as input (default: `Node`).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node it expects.\n * * If the plugin sets a {@link Parser `Parser`}, this should be\n * `string`.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be the\n * node it expects.\n * @template [Output=Input]\n * Value that is yielded as output (default: `Input`).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node that that yields.\n * * If the plugin sets a {@link Parser `Parser`}, this should be the\n * node that it yields.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be\n * result it yields.\n * @typedef {(\n * (this: Processor, ...parameters: PluginParameters) =>\n * Input extends string ? // Parser.\n * Output extends Node | undefined ? undefined | void : never :\n * Output extends CompileResults ? // Compiler.\n * Input extends Node | undefined ? undefined | void : never :\n * Transformer<\n * Input extends Node ? Input : Node,\n * Output extends Node ? Output : Node\n * > | undefined | void\n * )} Plugin\n * Single plugin.\n *\n * Plugins configure the processors they are applied on in the following\n * ways:\n *\n * * they change the processor, such as the parser, the compiler, or by\n * configuring data\n * * they specify how to handle trees and files\n *\n * In practice, they are functions that can receive options and configure the\n * processor (`this`).\n *\n * > \uD83D\uDC49 **Note**: plugins are called when the processor is *frozen*, not when\n * > they are applied.\n */\n\n/**\n * Tuple of a plugin and its configuration.\n *\n * The first item is a plugin, the rest are its parameters.\n *\n * @template {Array} [TupleParameters=[]]\n * Arguments passed to the plugin (default: `[]`, the empty tuple).\n * @template {Node | string | undefined} [Input=undefined]\n * Value that is expected as input (optional).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node it expects.\n * * If the plugin sets a {@link Parser `Parser`}, this should be\n * `string`.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be the\n * node it expects.\n * @template [Output=undefined] (optional).\n * Value that is yielded as output.\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node that that yields.\n * * If the plugin sets a {@link Parser `Parser`}, this should be the\n * node that it yields.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be\n * result it yields.\n * @typedef {(\n * [\n * plugin: Plugin,\n * ...parameters: TupleParameters\n * ]\n * )} PluginTuple\n */\n\n/**\n * @typedef Preset\n * Sharable configuration.\n *\n * They can contain plugins and settings.\n * @property {PluggableList | undefined} [plugins]\n * List of plugins and presets (optional).\n * @property {Settings | undefined} [settings]\n * Shared settings for parsers and compilers (optional).\n */\n\n/**\n * @template {VFile} [File=VFile]\n * The file that the callback receives (default: `VFile`).\n * @callback ProcessCallback\n * Callback called when the process is done.\n *\n * Called with either an error or a result.\n * @param {Error | undefined} [error]\n * Fatal error (optional).\n * @param {File | undefined} [file]\n * Processed file (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The tree that the callback receives (default: `Node`).\n * @callback RunCallback\n * Callback called when transformers are done.\n *\n * Called with either an error or results.\n * @param {Error | undefined} [error]\n * Fatal error (optional).\n * @param {Tree | undefined} [tree]\n * Transformed tree (optional).\n * @param {VFile | undefined} [file]\n * File (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Output=Node]\n * Node type that the transformer yields (default: `Node`).\n * @callback TransformCallback\n * Callback passed to transforms.\n *\n * If the signature of a `transformer` accepts a third argument, the\n * transformer may perform asynchronous operations, and must call it.\n * @param {Error | undefined} [error]\n * Fatal error to stop the process (optional).\n * @param {Output | undefined} [tree]\n * New, changed, tree (optional).\n * @param {VFile | undefined} [file]\n * New, changed, file (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Input=Node]\n * Node type that the transformer expects (default: `Node`).\n * @template {Node} [Output=Input]\n * Node type that the transformer yields (default: `Input`).\n * @callback Transformer\n * Transformers handle syntax trees and files.\n *\n * They are functions that are called each time a syntax tree and file are\n * passed through the run phase.\n * When an error occurs in them (either because it\u2019s thrown, returned,\n * rejected, or passed to `next`), the process stops.\n *\n * The run phase is handled by [`trough`][trough], see its documentation for\n * the exact semantics of these functions.\n *\n * > \uD83D\uDC49 **Note**: you should likely ignore `next`: don\u2019t accept it.\n * > it supports callback-style async work.\n * > But promises are likely easier to reason about.\n *\n * [trough]: https://github.com/wooorm/trough#function-fninput-next\n * @param {Input} tree\n * Tree to handle.\n * @param {VFile} file\n * File to handle.\n * @param {TransformCallback