import{g as t,c as n,a as o}from"./p-9817ba8b.js";import{m as s,n as e,e as c,p as r,c as i}from"./p-f44f0a67.js";import"./p-9a866be1.js";
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const u=new WeakMap;const a=(t,n,o,s=0)=>{if(u.has(t)===o){return}if(o){l(t,n,s)}else{d(t,n)}};const f=t=>t===t.getRootNode().activeElement;const l=(t,n,o)=>{const s=n.parentNode;const e=n.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";n.style.transform=`translate3d(${r}px,${o}px,0) scale(0)`};const d=(t,n)=>{const o=u.get(t);if(o){u.delete(t);o.remove()}t.style.pointerEvents="";n.style.transform=""};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const w=(t,n,o)=>{if(!o||!n){return()=>{}}const c=o=>{if(f(n)){a(t,n,o)}};const r=()=>a(t,n,false);const i=()=>c(true);const u=()=>c(false);s(o,"ionScrollStart",i);s(o,"ionScrollEnd",u);n.addEventListener("blur",r);return()=>{e(o,"ionScrollStart",i);e(o,"ionScrollEnd",u);n.addEventListener("ionBlur",r)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const p="input, textarea, [no-blur], [contenteditable]";const h=()=>{let t=true;let n=false;const o=document;const c=()=>{n=true};const r=()=>{t=true};const i=s=>{if(n){n=false;return}const e=o.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(o,"ionScrollStart",c);o.addEventListener("focusin",r,true);o.addEventListener("touchend",i,false);return()=>{e(o,"ionScrollStart",c,true);o.removeEventListener("focusin",r,true);o.removeEventListener("touchend",i,false)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const m=.3;const S=(t,n,o)=>{const s=t.closest("ion-item,[ion-item]")||t;return b(s.getBoundingClientRect(),n.getBoundingClientRect(),o,t.ownerDocument.defaultView.innerHeight)};const b=(t,n,o,s)=>{const e=t.top;const c=t.bottom;const r=n.top;const i=Math.min(n.bottom,s-o);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/m;const S=Math.min(400,Math.max(150,h));return{scrollAmount:w,scrollDuration:S,scrollPadding:o,inputSafeY:-(e-u)+4}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const y=(t,n,o,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(n)){M(t,n,o,s,e)}};t.addEventListener("touchstart",i,{capture:true,passive:true});t.addEventListener("touchend",u,true);return()=>{t.removeEventListener("touchstart",i,true);t.removeEventListener("touchend",u,true)}};const M=async(o,s,e,r,i)=>{if(!e&&!r){return}const u=S(o,e||r,i);if(e&&Math.abs(u.scrollAmount)<4){s.focus();return}a(o,s,true,u.inputSafeY);s.focus();c((()=>o.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 n(e,0,u.scrollAmount,u.scrollDuration)}a(o,s,false,u.inputSafeY);s.focus()};const i=()=>{window.removeEventListener("ionKeyboardDidShow",i);window.addEventListener("ionKeyboardDidShow",r)};if(e){const n=await t(e);const o=n.scrollHeight-n.clientHeight;if(u.scrollAmount>o-n.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,n,o)=>{if(n&&o){const s=n.x-o.x;const e=n.y-o.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 n=document;const o=n=>{g(n.target,t)};const s=t=>{g(t.target,0)};n.addEventListener("focusin",o);n.addEventListener("focusout",s);return()=>{n.removeEventListener("focusin",o);n.removeEventListener("focusout",s)}};const g=(t,n)=>{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=o(t);if(c===null){return}const r=c[x];if(r){clearTimeout(r)}if(n>0){c.style.setProperty("--keyboard-offset",`${n}px`)}else{c[x]=setTimeout((()=>{c.style.setProperty("--keyboard-offset","0px")}),120)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const k=true;const v=true;const I=t=>{const n=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(n.querySelectorAll("ion-input, ion-textarea"));const f=new WeakMap;const l=new WeakMap;const d=async t=>{await new Promise((n=>i(t,n)));const n=t.shadowRoot||t;const r=n.querySelector("input")||n.querySelector("textarea");const u=o(t);const a=!u?t.closest("ion-footer"):null;if(!r){return}if(!!u&&c&&!f.has(t)){const n=w(t,r,u);f.set(t,n)}if((!!u||!!a)&&e&&!l.has(t)){const n=y(t,r,u,a,s);l.set(t,n)}};const p=t=>{if(c){const n=f.get(t);if(n){n()}f.delete(t)}if(e){const n=l.get(t);if(n){n()}l.delete(t)}};if(r&&k){h()}if(u&&v){T(s)}for(const t of a){d(t)}n.addEventListener("ionInputDidLoad",(t=>{d(t.detail)}));n.addEventListener("ionInputDidUnload",(t=>{p(t.detail)}))};export{I as startInputShims};
//# sourceMappingURL=p-09ceb57d.js.map