import{i as t}from"./chunk-3488a752.js";const e=new WeakMap;function n(t,n,o,r=0){e.has(t)!==o&&(o?function(t,n,o){const r=n.parentNode,i=n.cloneNode(!1);i.classList.add("cloned-input"),i.tabIndex=-1,r.appendChild(i),e.set(t,i);const s="rtl"===t.ownerDocument.dir?9999:-9999;t.style.pointerEvents="none",n.style.transform=`translate3d(${s}px,${o}px,0) scale(0)`}(t,n,r):function(t,n){const o=e.get(t);o&&(e.delete(t),o.remove()),t.style.pointerEvents="",n.style.transform=""}(t,n))}function o(t){return t===t.getRootNode().activeElement}const r="input, textarea, [no-blur]",i=.3;function s(e,r,s,a){let c;const u=e=>{c=t(e)},l=u=>{if(!c)return;(function(t,e,n){if(c&&n){const t=c.x-n.x,e=c.y-n.y;return t*t+e*e>36}return!1})(0,0,t(u))||o(r)||(u.preventDefault(),u.stopPropagation(),function(t,e,o,r){const s=function(t,e,n){return function(e,n,o,r){const s=e.top,a=e.bottom,c=n.top,u=c+15,l=.5*Math.min(n.bottom,t.ownerDocument.defaultView.innerHeight-o)-a,d=u-s,f=Math.round(l<0?-l:d>0?-d:0),m=Math.min(f,s-c),p=Math.abs(m);return{scrollAmount:m,scrollDuration:Math.min(400,Math.max(150,p/i)),scrollPadding:o,inputSafeY:4-(s-u)}}((t.closest("ion-item,[ion-item]")||t).getBoundingClientRect(),e.getBoundingClientRect(),n)}(t,o,r);Math.abs(s.scrollAmount)<4?e.focus():(n(t,e,!0,s.inputSafeY),e.focus(),o.scrollByPoint(0,s.scrollAmount,s.scrollDuration).then(()=>{n(t,e,!1,s.inputSafeY),e.focus()}))}(e,r,s,a))};return e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",l,!0),()=>{e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",l,!0)}}const a="$ionPaddingTimer";function c(t,e){if("INPUT"!==t.tagName)return;if(t.parentElement&&"ION-INPUT"===t.parentElement.tagName)return;if(t.parentElement&&t.parentElement.parentElement&&"ION-SEARCHBAR"===t.parentElement.parentElement.tagName)return;const n=t.closest("ion-content");if(null===n)return;const o=n[a];o&&clearTimeout(o),e>0?n.style.setProperty("--keyboard-offset",`${e}px`):n[a]=setTimeout(()=>{n.style.setProperty("--keyboard-offset","0px")},120)}const u=!0,l=!0;function d(t,e){const i=e.getNumber("keyboardHeight",290),a=e.getBoolean("scrollAssist",!0),d=e.getBoolean("hideCaretOnScroll",!0),f=e.getBoolean("inputBlurring",!0),m=e.getBoolean("scrollPadding",!0),p=new WeakMap,E=new WeakMap;function g(t){const e=(t.shadowRoot||t).querySelector("input")||(t.shadowRoot||t).querySelector("textarea"),r=t.closest("ion-content");if(e){if(r&&d&&!p.has(t)){const i=function(t,e,r){if(!r||!e)return()=>{};const i=r=>{o(e)&&n(t,e,r)},s=()=>n(t,e,!1),a=()=>i(!0),c=()=>i(!1);return r.addEventListener("ionScrollStart",a),r.addEventListener("ionScrollEnd",c),e.addEventListener("blur",s),()=>{r.removeEventListener("ionScrollStart",a),r.removeEventListener("ionScrollEnd",c),e.addEventListener("ionBlur",s)}}(t,e,r);p.set(t,i)}if(r&&a&&!E.has(t)){const n=s(t,e,r,i);E.set(t,n)}}}f&&u&&function(t){let e=!0,n=!1;t.addEventListener("ionScrollStart",function(){n=!0}),t.addEventListener("focusin",function(){e=!0},!0),t.addEventListener("touchend",function(o){if(n)return void(n=!1);const i=t.activeElement;if(!i)return;if(i.matches(r))return;const s=o.target;s!==i&&(s.matches(r)||s.closest(r)||(e=!1,setTimeout(()=>{e||i.blur()},50)))},!1)}(t),m&&l&&function(t,e){t.addEventListener("focusin",function(t){c(t.target,e)}),t.addEventListener("focusout",function(t){c(t.target,0)})}(t,i);const v=Array.from(t.querySelectorAll("ion-input, ion-textarea"));for(const t of v)g(t);t.body.addEventListener("ionInputDidLoad",t=>{g(t.target)}),t.body.addEventListener("ionInputDidUnload",t=>{!function(t){if(d){const e=p.get(t);e&&e(),p.delete(t)}if(a){const e=E.get(t);e&&e(),E.delete(t)}}(t.target)})}export{d as startInputShims};