Files

1 line
28 KiB
Plaintext

{"version":3,"file":"dropdown.mjs","names":["pkg.version"],"sources":["../../../src/strings/showClass.ts","../../../src/strings/dataBsToggle.ts","../../../src/strings/dropdownClasses.ts","../../../src/strings/dropdownComponent.ts","../../../src/strings/dropdownMenuClass.ts","../../../src/util/isEmptyAnchor.ts","../../../src/util/isDisabled.ts","../../../package.json","../../../src/version.ts","../../../src/components/base-component.ts","../../../src/components/dropdown.ts"],"sourcesContent":["/**\n * Global namespace for most components `show` class.\n */\nconst showClass = \"show\";\nexport default showClass;\n","/**\n * Global namespace for most components `toggle` option.\n */\nconst dataBsToggle = \"data-bs-toggle\";\nexport default dataBsToggle;\n","/**\n * Global namespace for `Dropdown` types / classes.\n */\nconst dropdownMenuClasses = [\"dropdown\", \"dropup\", \"dropstart\", \"dropend\"];\nexport default dropdownMenuClasses;\n","/** @type {string} */\nconst dropdownComponent = \"Dropdown\";\nexport default dropdownComponent;\n","/**\n * Global namespace for `.dropdown-menu`.\n */\nconst dropdownMenuClass = \"dropdown-menu\";\nexport default dropdownMenuClass;\n","import { closest, getAttribute, hasAttribute } from \"@thednp/shorty\";\n\n/**\n * Checks if an *event.target* or its parent has an `href=\"#\"` value.\n * We need to prevent jumping around onclick, don't we?\n *\n * @param element the target element\n * @returns the query result\n */\nconst isEmptyAnchor = (element: HTMLElement) => {\n // `EventTarget` must be `HTMLElement`\n const parentAnchor = closest(element, \"A\");\n return (\n (element.tagName === \"A\" &&\n // anchor href starts with #\n hasAttribute(element, \"href\") &&\n (getAttribute(element, \"href\"))?.slice(-1) === \"#\") ||\n // OR a child of an anchor with href starts with #\n (parentAnchor &&\n hasAttribute(parentAnchor, \"href\") &&\n (getAttribute(parentAnchor, \"href\"))?.slice(-1) === \"#\")\n );\n};\nexport default isEmptyAnchor;\n","import { getAttribute, hasClass } from \"@thednp/shorty\";\n\n/**\n * Check if interactive element is disabled.\n * @param target either a `<button>` or an `<a>`\n * @returns whether the target is disabled\n */\nconst isDisabled = (target: Element) => {\n return hasClass(target, \"disabled\") ||\n getAttribute(target, \"disabled\") === \"true\";\n};\n\nexport default isDisabled;\n","","import pkg from \"../package.json\" with { type: \"json\" };\n\nconst Version = pkg.version;\n\nexport default Version;\n","/* Native JavaScript for Bootstrap 5 | Base Component\n----------------------------------------------------- */\nimport {\n Data,\n isElement,\n isString,\n normalizeOptions,\n ObjectKeys,\n querySelector,\n} from \"@thednp/shorty\";\n\nimport type { BaseOptions } from \"~/interface/baseComponent\";\nimport Version from \"~/version\";\n\n/** Returns a new `BaseComponent` instance. */\nexport default class BaseComponent {\n declare element: Element;\n declare options?: BaseOptions;\n\n /**\n * @param target `Element` or selector string\n * @param config component instance options\n */\n constructor(target: Element | string, config?: BaseOptions) {\n let element: Element | null;\n\n try {\n if (isElement(target)) {\n element = target as Element;\n } else if (isString(target)) {\n element = querySelector(target);\n // istanbul ignore else @preserve\n if (!element) throw Error(`\"${target}\" is not a valid selector.`);\n } else {\n throw Error(`your target is not an instance of HTMLElement.`);\n }\n } catch (e) {\n throw Error(`${this.name} Error: ${(e as Error).message}`);\n }\n\n const prevInstance = Data.get<typeof this>(element, this.name);\n /* istanbul ignore else @preserve */\n if (prevInstance) {\n // remove previously attached event listeners\n // to avoid memory leaks\n prevInstance._toggleEventListeners();\n }\n\n this.element = element;\n this.options = this.defaults && ObjectKeys(this.defaults).length\n ? normalizeOptions(element, this.defaults, config || {}, \"bs\")\n : /* istanbul ignore next @preserve */ {};\n\n Data.set(element, this.name, this);\n }\n\n // istanbul ignore next @preserve\n get version() {\n return Version;\n }\n\n // istanbul ignore next @preserve\n get name() {\n return \"BaseComponent\";\n }\n\n // istanbul ignore next @preserve\n get defaults() {\n return {};\n }\n\n /** just to have something to extend from */\n // istanbul ignore next @preserve coverage wise this isn't important\n _toggleEventListeners = () => {\n // do something to please linters\n };\n\n /** Removes component from target element. */\n dispose() {\n Data.remove<typeof this>(this.element, this.name);\n ObjectKeys(this).forEach((prop) => {\n delete this[prop];\n });\n }\n}\n","/* Native JavaScript for Bootstrap 5 | Dropdown\n----------------------------------------------- */\nimport {\n addClass,\n ariaExpanded,\n closest,\n createCustomEvent,\n CSS4Declaration,\n dispatchEvent,\n focus,\n focusEvent,\n getAttribute,\n getBoundingClientRect,\n getDocument,\n getDocumentElement,\n getElementsByClassName,\n getElementStyle,\n getInstance,\n hasClass,\n isHTMLElement,\n isRTL,\n keyArrowDown,\n keyArrowUp,\n KeyboardEvent,\n keydownEvent,\n keyEscape,\n keyupEvent,\n mouseclickEvent,\n mousedownEvent,\n MouseEvent,\n ObjectAssign,\n removeClass,\n setAttribute,\n setElementStyle,\n} from \"@thednp/shorty\";\n\nimport { addListener, removeListener } from \"@thednp/event-listener\";\nimport PositionObserver from \"@thednp/position-observer\";\n\nimport showClass from \"~/strings/showClass\";\nimport dataBsToggle from \"~/strings/dataBsToggle\";\nimport dropdownClasses from \"~/strings/dropdownClasses\";\nimport dropdownComponent from \"~/strings/dropdownComponent\";\nimport dropdownMenuClass from \"~/strings/dropdownMenuClass\";\nimport isEmptyAnchor from \"~/util/isEmptyAnchor\";\nimport isDisabled from \"~/util/isDisabled\";\nimport BaseComponent from \"./base-component\";\nimport type { DropdownEvent, DropdownOptions } from \"~/interface/dropdown\";\n\n// DROPDOWN PRIVATE GC\n// ===================\nconst [dropdownString, dropupString, dropstartString, dropendString] =\n dropdownClasses;\nconst dropdownSelector = `[${dataBsToggle}=\"${dropdownString}\"]`;\n\n/**\n * Static method which returns an existing `Dropdown` instance associated\n * to a target `Element`.\n */\nconst getDropdownInstance = (element: Element) =>\n getInstance<Dropdown>(element, dropdownComponent);\n\n/**\n * A `Dropdown` initialization callback.\n */\nconst dropdownInitCallback = (element: Element) => new Dropdown(element);\n\n// DROPDOWN PRIVATE GC\n// ===================\n// const dropdownMenuStartClass = `${dropdownMenuClass}-start`;\nconst dropdownMenuEndClass = `${dropdownMenuClass}-end`;\nconst verticalClass = [dropdownString, dropupString];\nconst horizontalClass = [dropstartString, dropendString];\nconst menuFocusTags = [\"A\", \"BUTTON\"];\n\nconst dropdownDefaults = {\n offset: 5, // [number] 5(px)\n display: \"dynamic\", // [dynamic|static]\n};\n\ntype DropdownEventProps = { relatedTarget: Element & EventTarget };\n\n// DROPDOWN CUSTOM EVENTS\n// ======================\nconst showDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `show.bs.${dropdownString}`,\n);\nconst shownDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `shown.bs.${dropdownString}`,\n);\nconst hideDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `hide.bs.${dropdownString}`,\n);\nconst hiddenDropdownEvent = createCustomEvent<\n DropdownEventProps,\n DropdownEvent\n>(`hidden.bs.${dropdownString}`);\nconst updatedDropdownEvent = createCustomEvent<\n DropdownEventProps,\n DropdownEvent\n>(`updated.bs.${dropdownString}`);\n\n// DROPDOWN PRIVATE METHODS\n// ========================\n/**\n * Apply specific style or class names to a `.dropdown-menu` to automatically\n * accomodate the layout and the page scroll.\n *\n * @param self the `Dropdown` instance\n */\nconst styleDropdown = (self: Dropdown) => {\n const { element, menu, parentElement, options } = self;\n const { offset } = options;\n // don't apply any style on mobile view\n // istanbul ignore if @preserve: this test requires a navbar\n if (getElementStyle(menu, \"position\") === \"static\") return;\n\n const RTL = isRTL(element);\n const menuEnd = hasClass(menu, dropdownMenuEndClass);\n\n // reset menu offset and position\n const resetProps = [\"margin\", \"top\", \"bottom\", \"left\", \"right\"];\n resetProps.forEach((p) => {\n const style: { [key: string]: string } = {};\n style[p] = \"\";\n setElementStyle(menu, style);\n });\n\n // set initial position class\n // take into account .btn-group parent as .dropdown\n // this requires navbar/btn-group/input-group\n // istanbul ignore next @preserve - fallback position\n let positionClass = dropdownClasses.find((c) => hasClass(parentElement, c)) ||\n dropdownString;\n\n const dropdownMargin: { [key: string]: number[] } = {\n dropdown: [offset, 0, 0],\n dropup: [0, 0, offset],\n dropstart: RTL ? [-1, 0, 0, offset] : [-1, offset, 0],\n dropend: RTL ? [-1, offset, 0] : [-1, 0, 0, offset],\n };\n\n const dropdownPosition: { [key: string]: Partial<CSS4Declaration> } = {\n dropdown: { top: \"100%\" },\n dropup: { top: \"auto\", bottom: \"100%\" },\n dropstart: RTL\n ? { left: \"100%\", right: \"auto\" }\n : { left: \"auto\", right: \"100%\" },\n dropend: RTL\n ? { left: \"auto\", right: \"100%\" }\n : { left: \"100%\", right: \"auto\" },\n menuStart: RTL\n ? { right: \"0\", left: \"auto\" }\n : { right: \"auto\", left: \"0\" },\n menuEnd: RTL ? { right: \"auto\", left: \"0\" } : { right: \"0\", left: \"auto\" },\n };\n\n const { offsetWidth: menuWidth, offsetHeight: menuHeight } = menu;\n\n const { clientWidth, clientHeight } = getDocumentElement(element);\n const {\n left: targetLeft,\n top: targetTop,\n width: targetWidth,\n height: targetHeight,\n } = getBoundingClientRect(element);\n\n // dropstart | dropend\n const leftFullExceed = targetLeft - menuWidth - offset < 0;\n // dropend\n const rightFullExceed =\n targetLeft + menuWidth + targetWidth + offset >= clientWidth;\n // dropstart | dropend\n const bottomExceed = targetTop + menuHeight + offset >= clientHeight;\n // dropdown\n const bottomFullExceed =\n targetTop + menuHeight + targetHeight + offset >= clientHeight;\n // dropup\n const topExceed = targetTop - menuHeight - offset < 0;\n // dropdown / dropup\n const leftExceed = ((!RTL && menuEnd) || (RTL && !menuEnd)) &&\n targetLeft + targetWidth - menuWidth < 0;\n const rightExceed = ((RTL && menuEnd) || (!RTL && !menuEnd)) &&\n targetLeft + menuWidth >= clientWidth;\n\n // recompute position\n // handle RTL as well\n if (\n horizontalClass.includes(positionClass) && leftFullExceed &&\n rightFullExceed\n ) {\n positionClass = dropdownString;\n }\n if (\n positionClass === dropstartString &&\n (!RTL ? leftFullExceed : rightFullExceed)\n ) {\n positionClass = dropendString;\n }\n if (\n positionClass === dropendString &&\n (RTL ? leftFullExceed : rightFullExceed)\n ) {\n positionClass = dropstartString;\n }\n if (positionClass === dropupString && topExceed && !bottomFullExceed) {\n positionClass = dropdownString;\n }\n if (positionClass === dropdownString && bottomFullExceed && !topExceed) {\n positionClass = dropupString;\n }\n\n // override position for horizontal classes\n if (horizontalClass.includes(positionClass) && bottomExceed) {\n ObjectAssign(dropdownPosition[positionClass], {\n top: \"auto\",\n bottom: 0,\n });\n }\n\n // override position for vertical classes\n if (verticalClass.includes(positionClass) && (leftExceed || rightExceed)) {\n // don't realign when menu is wider than window\n // in both RTL and non-RTL readability is KING\n let posAjust:\n | { left: \"auto\" | number; right: \"auto\" | number }\n | undefined = { left: \"auto\", right: \"auto\" };\n /* istanbul ignore else @preserve */\n if (!leftExceed && rightExceed && !RTL) {\n posAjust = { left: \"auto\", right: 0 };\n }\n /* istanbul ignore else @preserve */\n if (leftExceed && !rightExceed && RTL) {\n posAjust = { left: 0, right: \"auto\" };\n }\n /* istanbul ignore else @preserve */\n if (posAjust) {\n ObjectAssign(dropdownPosition[positionClass], posAjust);\n }\n }\n\n const margins: number[] = dropdownMargin[positionClass];\n setElementStyle(menu, {\n ...dropdownPosition[positionClass],\n margin: `${margins.map((x) => (x ? `${x}px` : x)).join(\" \")}`,\n });\n\n // override dropdown-menu-start | dropdown-menu-end\n if (verticalClass.includes(positionClass) && menuEnd) {\n // istanbul ignore else @preserve\n if (menuEnd) {\n // istanbul ignore next @preserve\n const endAdjust = (!RTL && leftExceed) || (RTL && rightExceed)\n ? \"menuStart\"\n : \"menuEnd\";\n setElementStyle(menu, dropdownPosition[endAdjust]);\n }\n }\n // trigger updated event\n dispatchEvent(parentElement, updatedDropdownEvent);\n};\n\n/**\n * Returns an `Array` of focusable items in the given dropdown-menu.\n *\n * @param menu the target menu\n * @returns all children of the dropdown menu\n */\nconst getMenuItems = (menu: HTMLElement) => {\n return Array.from(menu.children)\n .map((c) => {\n if (c && menuFocusTags.includes(c.tagName)) return c as HTMLElement;\n const { firstElementChild } = c;\n if (\n firstElementChild && menuFocusTags.includes(firstElementChild.tagName)\n ) {\n return firstElementChild as HTMLElement;\n }\n return null;\n })\n .filter((c) => c);\n};\n\n/**\n * Toggles on/off the listeners for the events that close the dropdown\n * as well as event that request a new position for the dropdown.\n *\n * @param {Dropdown} self the `Dropdown` instance\n */\nconst toggleDropdownDismiss = (self: Dropdown) => {\n const { element, options, menu } = self;\n const action = self.open ? addListener : removeListener;\n const doc = getDocument(element);\n\n action(doc, mouseclickEvent, dropdownDismissHandler);\n action(doc, focusEvent, dropdownDismissHandler);\n action(doc, keydownEvent, dropdownPreventScroll);\n action(doc, keyupEvent, dropdownKeyHandler);\n\n // istanbul ignore else @preserve\n if (options.display === \"dynamic\") {\n if (self.open) self._observer.observe(menu);\n else self._observer.disconnect();\n }\n};\n\n/**\n * Returns the currently open `.dropdown` element.\n *\n * @param element target\n * @returns the query result\n */\nconst getCurrentOpenDropdown = (\n element: Element,\n): Element | undefined => {\n const currentParent = [...dropdownClasses, \"btn-group\", \"input-group\"]\n .map((c) =>\n getElementsByClassName(`${c} ${showClass}`, getDocument(element))\n )\n .find((x) => x.length);\n\n if (currentParent && currentParent.length) {\n return [...(currentParent[0].children as HTMLCollectionOf<Element>)]\n .find((x) =>\n dropdownClasses.some((c) => c === getAttribute(x, dataBsToggle))\n );\n }\n return undefined;\n};\n\n// DROPDOWN EVENT HANDLERS\n// =======================\n/**\n * Handles the `click` event for the `Dropdown` instance.\n *\n * @param e event object\n */\nconst dropdownDismissHandler = (e: MouseEvent) => {\n const { target, type } = e;\n\n // istanbul ignore if @preserve\n if (!isHTMLElement(target)) return;\n\n // some weird FF bug #409\n const element = getCurrentOpenDropdown(target);\n const self = element && getDropdownInstance(element);\n\n // istanbul ignore if @preserve\n if (!self) return;\n\n const { parentElement, menu } = self;\n\n const isForm = parentElement &&\n parentElement.contains(target) &&\n (target.tagName === \"form\" || closest(target, \"form\") !== null);\n\n if (\n [mouseclickEvent, mousedownEvent].includes(type) &&\n isEmptyAnchor(target)\n ) {\n e.preventDefault();\n }\n\n // istanbul ignore else @preserve\n if (\n !isForm && type !== focusEvent && target !== element && target !== menu\n ) {\n self.hide();\n }\n};\n\n/**\n * Handles `click` event listener for `Dropdown`.\n *\n * @param e event object\n */\nfunction dropdownClickHandler(this: HTMLElement, e: MouseEvent<HTMLElement>) {\n const self = getDropdownInstance(this);\n\n // istanbul ignore if @preserve\n if (isDisabled(this)) return;\n // istanbul ignore if @preserve\n if (!self) return;\n\n e.stopPropagation();\n self.toggle();\n // istanbul ignore else @preserve\n if (isEmptyAnchor(this)) e.preventDefault();\n}\n\n/**\n * Prevents scroll when dropdown-menu is visible.\n *\n * @param e event object\n */\nconst dropdownPreventScroll = (e: KeyboardEvent) => {\n // istanbul ignore else @preserve\n if ([keyArrowDown, keyArrowUp].includes(e.code)) e.preventDefault();\n};\n\n/**\n * Handles keyboard `keydown` events for `Dropdown`.\n *\n * @param e keyboard key\n */\nfunction dropdownKeyHandler(this: Element, e: KeyboardEvent) {\n const { code } = e;\n const element = getCurrentOpenDropdown(this) as HTMLElement;\n /* istanbul ignore if @preserve */\n if (!element) return;\n\n const self = getDropdownInstance(element);\n const { activeElement } = getDocument(element) as Document & {\n activeElement: HTMLElement;\n };\n\n // istanbul ignore if @preserve\n if (!self || !activeElement) return;\n\n const { menu, open } = self;\n const menuItems = getMenuItems(menu);\n\n // arrow up & down\n if (\n menuItems && menuItems.length && [keyArrowDown, keyArrowUp].includes(code)\n ) {\n let idx = menuItems.indexOf(activeElement);\n // istanbul ignore else @preserve\n if (activeElement === element) {\n idx = 0;\n } else if (code === keyArrowUp) {\n idx = idx > 1 ? idx - 1 : 0;\n } else if (code === keyArrowDown) {\n idx = idx < menuItems.length - 1 ? idx + 1 : idx;\n }\n // istanbul ignore else @preserve\n if (menuItems[idx]) focus(menuItems[idx] as HTMLElement);\n }\n\n if (keyEscape === code && open) {\n self.toggle();\n focus(element);\n }\n}\n\n// DROPDOWN DEFINITION\n// ===================\n/** Returns a new Dropdown instance. */\nexport default class Dropdown extends BaseComponent {\n static selector = dropdownSelector;\n static init = dropdownInitCallback;\n static getInstance = getDropdownInstance;\n declare element: HTMLElement;\n declare options: DropdownOptions;\n declare open: boolean;\n declare parentElement: HTMLElement;\n declare menu: HTMLElement;\n declare _observer: PositionObserver;\n\n /**\n * @param target Element or string selector\n * @param config the instance options\n */\n constructor(target: Element | string, config?: Partial<DropdownOptions>) {\n super(target, config);\n\n // initialization element\n const { parentElement } = this.element;\n const [menu] = getElementsByClassName<HTMLElement>(\n dropdownMenuClass,\n parentElement as ParentNode,\n );\n\n // invalidate when dropdown-menu is missing\n // istanbul ignore if @preserve\n if (!menu) return;\n\n // set targets\n this.parentElement = parentElement as HTMLElement;\n this.menu = menu;\n this._observer = new PositionObserver(\n () => styleDropdown(this),\n );\n\n // add event listener\n this._toggleEventListeners(true);\n }\n\n /**\n * Returns component name string.\n */\n get name() {\n return dropdownComponent;\n }\n /**\n * Returns component default options.\n */\n get defaults() {\n return dropdownDefaults;\n }\n\n // DROPDOWN PUBLIC METHODS\n // =======================\n /** Shows/hides the dropdown menu to the user. */\n toggle() {\n if (this.open) this.hide();\n else this.show();\n }\n\n /** Shows the dropdown menu to the user. */\n show() {\n const { element, open, menu, parentElement } = this;\n\n // istanbul ignore if @preserve\n if (open) return;\n const currentElement = getCurrentOpenDropdown(element);\n const currentInstance = currentElement &&\n getDropdownInstance(currentElement);\n if (currentInstance) currentInstance.hide();\n\n // dispatch event\n [showDropdownEvent, shownDropdownEvent, updatedDropdownEvent].forEach(\n (e) => {\n e.relatedTarget = element;\n },\n );\n\n dispatchEvent(parentElement, showDropdownEvent);\n // istanbul ignore if @preserve\n if (showDropdownEvent.defaultPrevented) return;\n\n addClass(menu, showClass);\n addClass(parentElement, showClass);\n setAttribute(element, ariaExpanded, \"true\");\n\n // change menu position\n styleDropdown(this);\n\n this.open = !open;\n\n focus(element); // focus the element\n toggleDropdownDismiss(this);\n dispatchEvent(parentElement, shownDropdownEvent);\n }\n\n /** Hides the dropdown menu from the user. */\n hide() {\n const { element, open, menu, parentElement } = this;\n\n // istanbul ignore if @preserve\n if (!open) return;\n\n [hideDropdownEvent, hiddenDropdownEvent].forEach((e) => {\n e.relatedTarget = element as HTMLElement;\n });\n\n dispatchEvent(parentElement, hideDropdownEvent);\n // istanbul ignore if @preserve\n if (hideDropdownEvent.defaultPrevented) return;\n\n removeClass(menu, showClass);\n removeClass(parentElement, showClass);\n setAttribute(element, ariaExpanded, \"false\");\n\n this.open = !open;\n // only re-attach handler if the instance is not disposed\n toggleDropdownDismiss(this);\n dispatchEvent(parentElement, hiddenDropdownEvent);\n }\n\n /**\n * Toggles on/off the `click` event listener of the `Dropdown`.\n *\n * @param add when `true`, it will add the event listener\n */\n _toggleEventListeners = (add?: boolean) => {\n const action = add ? addListener : removeListener;\n action(this.element, mouseclickEvent, dropdownClickHandler);\n };\n\n /** Removes the `Dropdown` component from the target element. */\n dispose() {\n if (this.open) this.hide();\n\n this._toggleEventListeners();\n super.dispose();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA,MAAM,YAAY;;;;;;ACAlB,MAAM,eAAe;;;;;;ACArB,MAAM,sBAAsB;CAAC;CAAY;CAAU;CAAa;CAAU;;;;ACF1E,MAAM,oBAAoB;;;;;;ACE1B,MAAM,oBAAoB;;;;;;;;;;ACM1B,MAAM,iBAAiB,YAAyB;CAE9C,MAAM,eAAe,QAAQ,SAAS,IAAI;AAC1C,QACG,QAAQ,YAAY,OAEnB,aAAa,SAAS,OAAO,IAC5B,aAAa,SAAS,OAAO,EAAG,MAAM,GAAG,KAAK,OAEhD,gBACC,aAAa,cAAc,OAAO,IACjC,aAAa,cAAc,OAAO,EAAG,MAAM,GAAG,KAAK;;;;;;;;;ACb1D,MAAM,cAAc,WAAoB;AACtC,QAAO,SAAS,QAAQ,WAAW,IACjC,aAAa,QAAQ,WAAW,KAAK;;;;AEPzC,MAAM;;;;ACYN,IAAmB,gBAAnB,MAAkC;;;;;CAQhC,YAAE,QAAA,QAAA;EACF,IAAA;;AAGE,OAAI,UAAA,OAAA,CACA,WAAE;YACO,SAAQ,OAAG,EAAO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