{"version":3,"sources":["webpack:///./node_modules/@ionic/core/components/input-shims.js"],"names":["cloneMap","WeakMap","relocateInput","componentEl","inputEl","shouldRelocate","inputRelativeY","disabledClonedInput","has","addClone","removeClone","isFocused","input","getRootNode","activeElement","parentEl","parentNode","clonedEl","cloneNode","classList","add","tabIndex","disabled","appendChild","set","doc","ownerDocument","tx","dir","style","pointerEvents","transform","clone","get","delete","remove","enableHideCaretOnScroll","scrollEl","scrollHideCaret","shouldHideCaret","onBlur","hideCaret","showCaret","addEventListener","removeEventListener","SKIP_SELECTOR","enableInputBlurring","focused","didScroll","document","onScroll","onFocusin","onTouchend","ev","active","matches","tapped","target","closest","setTimeout","blur","SCROLL_ASSIST_SPEED","getScrollData","contentEl","keyboardHeight","_a","itemEl","calcScrollData","getBoundingClientRect","defaultView","innerHeight","inputRect","contentRect","platformHeight","inputTop","top","inputBottom","bottom","visibleAreaTop","visibleAreaBottom","Math","min","safeAreaTop","safeAreaBottom","distanceToBottom","distanceToTop","desiredScrollAmount","round","scrollAmount","distance","abs","duration","scrollDuration","max","scrollPadding","inputSafeY","enableScrollAssist","footerEl","disableClonedInput","coord","touchStart","touchEnd","endCoord","hasPointerMoved","jsSetFocus","capture","passive","async","scrollData","focus","click","window","scrollContentTimeout","scrollContent","undefined","clearTimeout","doubleKeyboardEventListener","totalScrollAmount","scrollHeight","clientHeight","scrollTop","type","threshold","startCoord","deltaX","x","deltaY","y","PADDING_TIMER_KEY","enableScrollPadding","setScrollPadding","onFocusout","_b","tagName","parentElement","el","timer","setProperty","INPUT_BLURRING","SCROLL_PADDING","startInputShims","config","platform","isIOS","isAndroid","getNumber","scrollAssist","getBoolean","inputBlurring","inputs","Array","from","querySelectorAll","hideCaretMap","scrollAssistMap","registerInput","Promise","resolve","inputRoot","shadowRoot","querySelector","rmFn","isDateInput","unregisterInput","fn","detail"],"mappings":"kHAAA;;;;AAMA,MAAMA,EAAW,IAAIC,QACfC,EAAgB,CAACC,EAAaC,EAASC,EAAgBC,EAAi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C,EAAU4D,EAAUjC,EAAgBgF,GAC1FU,EAAgBlI,IAAIrB,EAAa8J,KAG/BE,EAAmBhK,IACvB,GAAIsC,EAAW,CACb,MAAM2H,EAAKX,EAAaxH,IAAI9B,GACxBiK,GACFA,IAEFX,EAAavH,OAAO/B,GAEtB,GAAI+I,EAAc,CAChB,MAAMkB,EAAKV,EAAgBzH,IAAI9B,GAC3BiK,GACFA,IAEFV,EAAgBxH,OAAO/B,KAGvBiJ,GAAiBV,GACnB5F,IAEEgD,GAAiB6C,GACnBV,EAAoBjE,GAKtB,IAAK,MAAMpD,KAASyI,EAClBM,EAAc/I,GAGhBa,EAAIkB,iBAAiB,kBAAqBU,IACxCsG,EAActG,EAAGgH,UAEnB5I,EAAIkB,iBAAiB,oBAAuBU,IAC1C8G,EAAgB9G,EAAGgH","file":"js/chunk-2d0d6d65.849aca4b.js","sourcesContent":["/*!\n * (C) Ionic http://ionicframework.com - MIT License\n */\nimport { g as getScrollElement, c as scrollByPoint, a as findClosestIonContent } from './index9.js';\nimport { a as addEventListener, b as removeEventListener, r as raf, p as pointerCoord, c as componentOnReady } from './helpers.js';\n\nconst cloneMap = new WeakMap();\nconst relocateInput = (componentEl, inputEl, shouldRelocate, inputRelativeY = 0, disabledClonedInput = false) => {\n if (cloneMap.has(componentEl) === shouldRelocate) {\n return;\n }\n if (shouldRelocate) {\n addClone(componentEl, inputEl, inputRelativeY, disabledClonedInput);\n }\n else {\n removeClone(componentEl, inputEl);\n }\n};\n// TODO(FW-2832): type\nconst isFocused = (input) => {\n return input === input.getRootNode().activeElement;\n};\nconst addClone = (componentEl, inputEl, inputRelativeY, disabledClonedInput = false) => {\n // this allows for the actual input to receive the focus from\n // the user's touch event, but before it receives focus, it\n // moves the actual input to a location that will not screw\n // up the app's layout, and does not allow the native browser\n // to attempt to scroll the input into place (messing up headers/footers)\n // the cloned input fills the area of where native input should be\n // while the native input fakes out the browser by relocating itself\n // before it receives the actual focus event\n // We hide the focused input (with the visible caret) invisible by making it scale(0),\n const parentEl = inputEl.parentNode;\n // DOM WRITES\n const clonedEl = inputEl.cloneNode(false);\n clonedEl.classList.add('cloned-input');\n clonedEl.tabIndex = -1;\n /**\n * Making the cloned input disabled prevents\n * Chrome for Android from still scrolling\n * the entire page since this cloned input\n * will briefly be hidden by the keyboard\n * even though it is not focused.\n *\n * This is not needed on iOS. While this\n * does not cause functional issues on iOS,\n * the input still appears slightly dimmed even\n * if we set opacity: 1.\n */\n if (disabledClonedInput) {\n clonedEl.disabled = true;\n }\n parentEl.appendChild(clonedEl);\n cloneMap.set(componentEl, clonedEl);\n const doc = componentEl.ownerDocument;\n const tx = doc.dir === 'rtl' ? 9999 : -9999;\n componentEl.style.pointerEvents = 'none';\n inputEl.style.transform = `translate3d(${tx}px,${inputRelativeY}px,0) scale(0)`;\n};\nconst removeClone = (componentEl, inputEl) => {\n const clone = cloneMap.get(componentEl);\n if (clone) {\n cloneMap.delete(componentEl);\n clone.remove();\n }\n componentEl.style.pointerEvents = '';\n inputEl.style.transform = '';\n};\n\nconst enableHideCaretOnScroll = (componentEl, inputEl, scrollEl) => {\n if (!scrollEl || !inputEl) {\n return () => {\n return;\n };\n }\n const scrollHideCaret = (shouldHideCaret) => {\n if (isFocused(inputEl)) {\n relocateInput(componentEl, inputEl, shouldHideCaret);\n }\n };\n const onBlur = () => relocateInput(componentEl, inputEl, false);\n const hideCaret = () => scrollHideCaret(true);\n const showCaret = () => scrollHideCaret(false);\n addEventListener(scrollEl, 'ionScrollStart', hideCaret);\n addEventListener(scrollEl, 'ionScrollEnd', showCaret);\n inputEl.addEventListener('blur', onBlur);\n return () => {\n removeEventListener(scrollEl, 'ionScrollStart', hideCaret);\n removeEventListener(scrollEl, 'ionScrollEnd', showCaret);\n inputEl.removeEventListener('blur', onBlur);\n };\n};\n\nconst SKIP_SELECTOR = 'input, textarea, [no-blur], [contenteditable]';\nconst enableInputBlurring = () => {\n let focused = true;\n let didScroll = false;\n const doc = document;\n const onScroll = () => {\n didScroll = true;\n };\n const onFocusin = () => {\n focused = true;\n };\n const onTouchend = (ev) => {\n // if app did scroll return early\n if (didScroll) {\n didScroll = false;\n return;\n }\n const active = doc.activeElement;\n if (!active) {\n return;\n }\n // only blur if the active element is a text-input or a textarea\n if (active.matches(SKIP_SELECTOR)) {\n return;\n }\n // if the selected target is the active element, do not blur\n const tapped = ev.target;\n if (tapped === active) {\n return;\n }\n if (tapped.matches(SKIP_SELECTOR) || tapped.closest(SKIP_SELECTOR)) {\n return;\n }\n focused = false;\n // TODO FW-2796: find a better way, why 50ms?\n setTimeout(() => {\n if (!focused) {\n active.blur();\n }\n }, 50);\n };\n addEventListener(doc, 'ionScrollStart', onScroll);\n doc.addEventListener('focusin', onFocusin, true);\n doc.addEventListener('touchend', onTouchend, false);\n return () => {\n removeEventListener(doc, 'ionScrollStart', onScroll, true);\n doc.removeEventListener('focusin', onFocusin, true);\n doc.removeEventListener('touchend', onTouchend, false);\n };\n};\n\nconst SCROLL_ASSIST_SPEED = 0.3;\nconst getScrollData = (componentEl, contentEl, keyboardHeight) => {\n var _a;\n const itemEl = (_a = componentEl.closest('ion-item,[ion-item]')) !== null && _a !== void 0 ? _a : componentEl;\n return calcScrollData(itemEl.getBoundingClientRect(), contentEl.getBoundingClientRect(), keyboardHeight, componentEl.ownerDocument.defaultView.innerHeight // TODO(FW-2832): type\n );\n};\nconst calcScrollData = (inputRect, contentRect, keyboardHeight, platformHeight) => {\n // compute input's Y values relative to the body\n const inputTop = inputRect.top;\n const inputBottom = inputRect.bottom;\n // compute visible area\n const visibleAreaTop = contentRect.top;\n const visibleAreaBottom = Math.min(contentRect.bottom, platformHeight - keyboardHeight);\n // compute safe area\n const safeAreaTop = visibleAreaTop + 15;\n const safeAreaBottom = visibleAreaBottom * 0.75;\n // figure out if each edge of the input is within the safe area\n const distanceToBottom = safeAreaBottom - inputBottom;\n const distanceToTop = safeAreaTop - inputTop;\n // desiredScrollAmount is the negated distance to the safe area according to our calculations.\n const desiredScrollAmount = Math.round(distanceToBottom < 0 ? -distanceToBottom : distanceToTop > 0 ? -distanceToTop : 0);\n // our calculations make some assumptions that aren't always true, like the keyboard being closed when an input\n // gets focus, so make sure we don't scroll the input above the visible area\n const scrollAmount = Math.min(desiredScrollAmount, inputTop - visibleAreaTop);\n const distance = Math.abs(scrollAmount);\n const duration = distance / SCROLL_ASSIST_SPEED;\n const scrollDuration = Math.min(400, Math.max(150, duration));\n return {\n scrollAmount,\n scrollDuration,\n scrollPadding: keyboardHeight,\n inputSafeY: -(inputTop - safeAreaTop) + 4,\n };\n};\n\nconst enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardHeight, disableClonedInput = false) => {\n let coord;\n const touchStart = (ev) => {\n coord = pointerCoord(ev);\n };\n const touchEnd = (ev) => {\n // input cover touchend/mouseup\n if (!coord) {\n return;\n }\n // get where the touchend/mouseup ended\n const endCoord = pointerCoord(ev);\n // focus this input if the pointer hasn't moved XX pixels\n // and the input doesn't already have focus\n if (!hasPointerMoved(6, coord, endCoord) && !isFocused(inputEl)) {\n // begin the input focus process\n jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, disableClonedInput);\n }\n };\n componentEl.addEventListener('touchstart', touchStart, { capture: true, passive: true });\n componentEl.addEventListener('touchend', touchEnd, true);\n return () => {\n componentEl.removeEventListener('touchstart', touchStart, true);\n componentEl.removeEventListener('touchend', touchEnd, true);\n };\n};\nconst jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, disableClonedInput = false) => {\n if (!contentEl && !footerEl) {\n return;\n }\n const scrollData = getScrollData(componentEl, (contentEl || footerEl), keyboardHeight);\n if (contentEl && Math.abs(scrollData.scrollAmount) < 4) {\n // the text input is in a safe position that doesn't\n // require it to be scrolled into view, just set focus now\n inputEl.focus();\n return;\n }\n // temporarily move the focus to the focus holder so the browser\n // doesn't freak out while it's trying to get the input in place\n // at this point the native text input still does not have focus\n relocateInput(componentEl, inputEl, true, scrollData.inputSafeY, disableClonedInput);\n inputEl.focus();\n /**\n * Relocating/Focusing input causes the\n * click event to be cancelled, so\n * manually fire one here.\n */\n raf(() => componentEl.click());\n if (typeof window !== 'undefined') {\n let scrollContentTimeout;\n const scrollContent = async () => {\n // clean up listeners and timeouts\n if (scrollContentTimeout !== undefined) {\n clearTimeout(scrollContentTimeout);\n }\n window.removeEventListener('ionKeyboardDidShow', doubleKeyboardEventListener);\n window.removeEventListener('ionKeyboardDidShow', scrollContent);\n // scroll the input into place\n if (contentEl) {\n await scrollByPoint(contentEl, 0, scrollData.scrollAmount, scrollData.scrollDuration);\n }\n // the scroll view is in the correct position now\n // give the native text input focus\n relocateInput(componentEl, inputEl, false, scrollData.inputSafeY);\n // ensure this is the focused input\n inputEl.focus();\n };\n const doubleKeyboardEventListener = () => {\n window.removeEventListener('ionKeyboardDidShow', doubleKeyboardEventListener);\n window.addEventListener('ionKeyboardDidShow', scrollContent);\n };\n if (contentEl) {\n const scrollEl = await getScrollElement(contentEl);\n /**\n * scrollData will only consider the amount we need\n * to scroll in order to properly bring the input\n * into view. It will not consider the amount\n * we can scroll in the content element.\n * As a result, scrollData may request a greater\n * scroll position than is currently available\n * in the DOM. If this is the case, we need to\n * wait for the webview to resize/the keyboard\n * to show in order for additional scroll\n * bandwidth to become available.\n */\n const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;\n if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {\n /**\n * On iOS devices, the system will show a \"Passwords\" bar above the keyboard\n * after the initial keyboard is shown. This prevents the webview from resizing\n * until the \"Passwords\" bar is shown, so we need to wait for that to happen first.\n */\n if (inputEl.type === 'password') {\n // Add 50px to account for the \"Passwords\" bar\n scrollData.scrollAmount += 50;\n window.addEventListener('ionKeyboardDidShow', doubleKeyboardEventListener);\n }\n else {\n window.addEventListener('ionKeyboardDidShow', scrollContent);\n }\n /**\n * This should only fire in 2 instances:\n * 1. The app is very slow.\n * 2. The app is running in a browser on an old OS\n * that does not support Ionic Keyboard Events\n */\n scrollContentTimeout = setTimeout(scrollContent, 1000);\n return;\n }\n }\n scrollContent();\n }\n};\nconst hasPointerMoved = (threshold, startCoord, endCoord) => {\n if (startCoord && endCoord) {\n const deltaX = startCoord.x - endCoord.x;\n const deltaY = startCoord.y - endCoord.y;\n const distance = deltaX * deltaX + deltaY * deltaY;\n return distance > threshold * threshold;\n }\n return false;\n};\n\nconst PADDING_TIMER_KEY = '$ionPaddingTimer';\nconst enableScrollPadding = (keyboardHeight) => {\n const doc = document;\n // TODO(FW-2832): types\n const onFocusin = (ev) => {\n setScrollPadding(ev.target, keyboardHeight);\n };\n const onFocusout = (ev) => {\n setScrollPadding(ev.target, 0);\n };\n doc.addEventListener('focusin', onFocusin);\n doc.addEventListener('focusout', onFocusout);\n return () => {\n doc.removeEventListener('focusin', onFocusin);\n doc.removeEventListener('focusout', onFocusout);\n };\n};\nconst setScrollPadding = (input, keyboardHeight) => {\n var _a, _b;\n if (input.tagName !== 'INPUT') {\n return;\n }\n if (input.parentElement && input.parentElement.tagName === 'ION-INPUT') {\n return;\n }\n if (((_b = (_a = input.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.tagName) === 'ION-SEARCHBAR') {\n return;\n }\n const el = findClosestIonContent(input);\n if (el === null) {\n return;\n }\n const timer = el[PADDING_TIMER_KEY];\n if (timer) {\n clearTimeout(timer);\n }\n if (keyboardHeight > 0) {\n el.style.setProperty('--keyboard-offset', `${keyboardHeight}px`);\n }\n else {\n el[PADDING_TIMER_KEY] = setTimeout(() => {\n el.style.setProperty('--keyboard-offset', '0px');\n }, 120);\n }\n};\n\nconst INPUT_BLURRING = true;\nconst SCROLL_PADDING = true;\nconst startInputShims = (config, platform) => {\n const doc = document;\n const isIOS = platform === 'ios';\n const isAndroid = platform === 'android';\n /**\n * Hide Caret and Input Blurring are needed on iOS.\n * Scroll Assist and Scroll Padding are needed on iOS and Android\n * with Chrome web browser (not Chrome webview).\n */\n const keyboardHeight = config.getNumber('keyboardHeight', 290);\n const scrollAssist = config.getBoolean('scrollAssist', true);\n const hideCaret = config.getBoolean('hideCaretOnScroll', isIOS);\n const inputBlurring = config.getBoolean('inputBlurring', isIOS);\n const scrollPadding = config.getBoolean('scrollPadding', true);\n const inputs = Array.from(doc.querySelectorAll('ion-input, ion-textarea'));\n const hideCaretMap = new WeakMap();\n const scrollAssistMap = new WeakMap();\n const registerInput = async (componentEl) => {\n await new Promise((resolve) => componentOnReady(componentEl, resolve));\n const inputRoot = componentEl.shadowRoot || componentEl;\n const inputEl = inputRoot.querySelector('input') || inputRoot.querySelector('textarea');\n const scrollEl = findClosestIonContent(componentEl);\n const footerEl = !scrollEl ? componentEl.closest('ion-footer') : null;\n if (!inputEl) {\n return;\n }\n if (!!scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {\n const rmFn = enableHideCaretOnScroll(componentEl, inputEl, scrollEl);\n hideCaretMap.set(componentEl, rmFn);\n }\n /**\n * date/datetime-locale inputs on mobile devices show date picker\n * overlays instead of keyboards. As a result, scroll assist is\n * not needed. This also works around a bug in iOS <16 where\n * scroll assist causes the browser to lock up. See FW-1997.\n */\n const isDateInput = inputEl.type === 'date' || inputEl.type === 'datetime-local';\n if (!isDateInput &&\n (!!scrollEl || !!footerEl) &&\n scrollAssist &&\n !scrollAssistMap.has(componentEl)) {\n const rmFn = enableScrollAssist(componentEl, inputEl, scrollEl, footerEl, keyboardHeight, isAndroid);\n scrollAssistMap.set(componentEl, rmFn);\n }\n };\n const unregisterInput = (componentEl) => {\n if (hideCaret) {\n const fn = hideCaretMap.get(componentEl);\n if (fn) {\n fn();\n }\n hideCaretMap.delete(componentEl);\n }\n if (scrollAssist) {\n const fn = scrollAssistMap.get(componentEl);\n if (fn) {\n fn();\n }\n scrollAssistMap.delete(componentEl);\n }\n };\n if (inputBlurring && INPUT_BLURRING) {\n enableInputBlurring();\n }\n if (scrollPadding && SCROLL_PADDING) {\n enableScrollPadding(keyboardHeight);\n }\n // Input might be already loaded in the DOM before ion-device-hacks did.\n // At this point we need to look for all of the inputs not registered yet\n // and register them.\n for (const input of inputs) {\n registerInput(input);\n }\n // TODO(FW-2832): types\n doc.addEventListener('ionInputDidLoad', ((ev) => {\n registerInput(ev.detail);\n }));\n doc.addEventListener('ionInputDidUnload', ((ev) => {\n unregisterInput(ev.detail);\n }));\n};\n\nexport { startInputShims };\n"],"sourceRoot":""}