import{g as t,c as o,a as n}from"./p-5e38ef53.js";import{j as s,k as e,r as c,q as r,c as i}from"./p-7cbdb4ea.js";import"./p-b5cdbd99.js";
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const u=new WeakMap;const a=(t,o,n,s=0)=>{if(u.has(t)===n){return}if(n){l(t,o,s)}else{d(t,o)}};const f=t=>t===t.getRootNode().activeElement;const l=(t,o,n)=>{const s=o.parentNode;const e=o.cloneNode(false);e.classList.add("cloned-input");e.tabIndex=-1;s.appendChild(e);u.set(t,e);const c=t.ownerDocument;const r=c.dir==="rtl"?9999:-9999;t.style.pointerEvents="none";o.style.transform=`translate3d(${r}px,${n}px,0) scale(0)`};const d=(t,o)=>{const n=u.get(t);if(n){u.delete(t);n.remove()}t.style.pointerEvents="";o.style.transform=""};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const w=(t,o,n)=>{if(!n||!o){return()=>{}}const c=n=>{if(f(o)){a(t,o,n)}};const r=()=>a(t,o,false);const i=()=>c(true);const u=()=>c(false);s(n,"ionScrollStart",i);s(n,"ionScrollEnd",u);o.addEventListener("blur",r);return()=>{e(n,"ionScrollStart",i);e(n,"ionScrollEnd",u);o.addEventListener("ionBlur",r)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const p="input, textarea, [no-blur], [contenteditable]";const h=()=>{let t=true;let o=false;const n=document;const c=()=>{o=true};const r=()=>{t=true};const i=s=>{if(o){o=false;return}const e=n.activeElement;if(!e){return}if(e.matches(p)){return}const c=s.target;if(c===e){return}if(c.matches(p)||c.closest(p)){return}t=false;setTimeout((()=>{if(!t){e.blur()}}),50)};s(n,"ionScrollStart",c);n.addEventListener("focusin",r,true);n.addEventListener("touchend",i,false);return()=>{e(n,"ionScrollStart",c,true);n.removeEventListener("focusin",r,true);n.removeEventListener("touchend",i,false)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const S=.3;const m=(t,o,n)=>{const s=t.closest("ion-item,[ion-item]")||t;return b(s.getBoundingClientRect(),o.getBoundingClientRect(),n,t.ownerDocument.defaultView.innerHeight)};const b=(t,o,n,s)=>{const e=t.top;const c=t.bottom;const r=o.top;const i=Math.min(o.bottom,s-n);const u=r+15;const a=i*.75;const f=a-c;const l=u-e;const d=Math.round(f<0?-f:l>0?-l:0);const w=Math.min(d,e-r);const p=Math.abs(w);const h=p/S;const m=Math.min(400,Math.max(150,h));return{scrollAmount:w,scrollDuration:m,scrollPadding:n,inputSafeY:-(e-u)+4}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const y=(t,o,n,s,e)=>{let c;const i=t=>{c=r(t)};const u=i=>{if(!c){return}const u=r(i);if(!D(6,c,u)&&!f(o)){M(t,o,n,s,e)}};t.addEventListener("touchstart",i,true);t.addEventListener("touchend",u,true);return()=>{t.removeEventListener("touchstart",i,true);t.removeEventListener("touchend",u,true)}};const M=async(n,s,e,r,i)=>{if(!e&&!r){return}const u=m(n,e||r,i);if(e&&Math.abs(u.scrollAmount)<4){s.focus();return}a(n,s,true,u.inputSafeY);s.focus();c((()=>n.click()));if(typeof window!=="undefined"){let c;const r=async()=>{if(c!==undefined){clearTimeout(c)}window.removeEventListener("ionKeyboardDidShow",i);window.removeEventListener("ionKeyboardDidShow",r);if(e){await o(e,0,u.scrollAmount,u.scrollDuration)}a(n,s,false,u.inputSafeY);s.focus()};const i=()=>{window.removeEventListener("ionKeyboardDidShow",i);window.addEventListener("ionKeyboardDidShow",r)};if(e){const o=await t(e);const n=o.scrollHeight-o.clientHeight;if(u.scrollAmount>n-o.scrollTop){if(s.type==="password"){u.scrollAmount+=50;window.addEventListener("ionKeyboardDidShow",i)}else{window.addEventListener("ionKeyboardDidShow",r)}c=setTimeout(r,1e3);return}}r()}};const D=(t,o,n)=>{if(o&&n){const s=o.x-n.x;const e=o.y-n.y;const c=s*s+e*e;return c>t*t}return false};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const x="$ionPaddingTimer";const T=t=>{const o=document;const n=o=>{k(o.target,t)};const s=t=>{k(t.target,0)};o.addEventListener("focusin",n);o.addEventListener("focusout",s);return()=>{o.removeEventListener("focusin",n);o.removeEventListener("focusout",s)}};const k=(t,o)=>{var s,e;if(t.tagName!=="INPUT"){return}if(t.parentElement&&t.parentElement.tagName==="ION-INPUT"){return}if(((e=(s=t.parentElement)===null||s===void 0?void 0:s.parentElement)===null||e===void 0?void 0:e.tagName)==="ION-SEARCHBAR"){return}const c=n(t);if(c===null){return}const r=c[x];if(r){clearTimeout(r)}if(o>0){c.style.setProperty("--keyboard-offset",`${o}px`)}else{c[x]=setTimeout((()=>{c.style.setProperty("--keyboard-offset","0px")}),120)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const g=true;const I=true;const K=t=>{const o=document;const s=t.getNumber("keyboardHeight",290);const e=t.getBoolean("scrollAssist",true);const c=t.getBoolean("hideCaretOnScroll",true);const r=t.getBoolean("inputBlurring",true);const u=t.getBoolean("scrollPadding",true);const a=Array.from(o.querySelectorAll("ion-input, ion-textarea"));const f=new WeakMap;const l=new WeakMap;const d=async t=>{await new Promise((o=>i(t,o)));const o=t.shadowRoot||t;const r=o.querySelector("input")||o.querySelector("textarea");const u=n(t);const a=!u?t.closest("ion-footer"):null;if(!r){return}if(!!u&&c&&!f.has(t)){const o=w(t,r,u);f.set(t,o)}if((!!u||!!a)&&e&&!l.has(t)){const o=y(t,r,u,a,s);l.set(t,o)}};const p=t=>{if(c){const o=f.get(t);if(o){o()}f.delete(t)}if(e){const o=l.get(t);if(o){o()}l.delete(t)}};if(r&&g){h()}if(u&&I){T(s)}for(const t of a){d(t)}o.addEventListener("ionInputDidLoad",(t=>{d(t.detail)}));o.addEventListener("ionInputDidUnload",(t=>{p(t.detail)}))};export{K as startInputShims};
//# sourceMappingURL=p-8718c965.js.map