import{g as t,c as o,a as n}from"./p-0f957630.js";import{f as s,g as e,r as c,c as i}from"./p-8538de1a.js";import{a as r,K as a}from"./p-565ab761.js";import"./p-b4215fed.js";import"./p-eb6f4547.js";import"./p-c76826f0.js";
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const f=new WeakMap;const u=(t,o,n,s=0,e=false)=>{if(f.has(t)===n){return}if(n){d(t,o,s,e)}else{p(t,o)}};const l=t=>t===t.getRootNode().activeElement;const d=(t,o,n,s=false)=>{const e=o.parentNode;const c=o.cloneNode(false);c.classList.add("cloned-input");c.tabIndex=-1;if(s){c.disabled=true}e.appendChild(c);f.set(t,c);const i=t.ownerDocument;const r=i.dir==="rtl"?9999:-9999;t.style.pointerEvents="none";o.style.transform=`translate3d(${r}px,${n}px,0) scale(0)`};const p=(t,o)=>{const n=f.get(t);if(n){f.delete(t);n.remove()}t.style.pointerEvents="";o.style.transform=""};const w=50;
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const m=(t,o,n)=>{if(!n||!o){return()=>{}}const c=n=>{if(l(o)){u(t,o,n)}};const i=()=>u(t,o,false);const r=()=>c(true);const a=()=>c(false);s(n,"ionScrollStart",r);s(n,"ionScrollEnd",a);o.addEventListener("blur",i);return()=>{e(n,"ionScrollStart",r);e(n,"ionScrollEnd",a);o.removeEventListener("blur",i)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const S="input, textarea, [no-blur], [contenteditable]";const h=()=>{let t=true;let o=false;const n=document;const c=()=>{o=true};const i=()=>{t=true};const r=s=>{if(o){o=false;return}const e=n.activeElement;if(!e){return}if(e.matches(S)){return}const c=s.target;if(c===e){return}if(c.matches(S)||c.closest(S)){return}t=false;setTimeout((()=>{if(!t){e.blur()}}),50)};s(n,"ionScrollStart",c);n.addEventListener("focusin",i,true);n.addEventListener("touchend",r,false);return()=>{e(n,"ionScrollStart",c,true);n.removeEventListener("focusin",i,true);n.removeEventListener("touchend",r,false)}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const b=.3;const y=(t,o,n)=>{var s;const e=(s=t.closest("ion-item,[ion-item]"))!==null&&s!==void 0?s:t;return M(e.getBoundingClientRect(),o.getBoundingClientRect(),n,t.ownerDocument.defaultView.innerHeight)};const M=(t,o,n,s)=>{const e=t.top;const c=t.bottom;const i=o.top;const r=Math.min(o.bottom,s-n);const a=i+15;const f=r-w;const u=f-c;const l=a-e;const d=Math.round(u<0?-u:l>0?-l:0);const p=Math.min(d,e-i);const m=Math.abs(p);const S=m/b;const h=Math.min(400,Math.max(150,S));return{scrollAmount:p,scrollDuration:h,scrollPadding:n,inputSafeY:-(e-a)+4}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const D="$ionPaddingTimer";const x=(t,o,n)=>{const s=t[D];if(s){clearTimeout(s)}if(o>0){t.style.setProperty("--keyboard-offset",`${o}px`)}else{t[D]=setTimeout((()=>{t.style.setProperty("--keyboard-offset","0px");if(n){n()}}),120)}};const g=(t,o,n)=>{const s=()=>{if(o){x(o,0,n)}};t.addEventListener("focusout",s,{once:true})};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */let k=0;const K="data-ionic-skip-scroll-assist";const j=(t,o,n,s,e,c,i,a=false)=>{const f=c&&(i===undefined||i.mode===r.None);const u=async()=>{if(o.hasAttribute(K)){o.removeAttribute(K);return}P(t,o,n,s,e,f,a)};t.addEventListener("focusin",u,true);return()=>{t.removeEventListener("focusin",u,true)}};const T=t=>{if(document.activeElement===t){return}t.setAttribute(K,"true");t.focus()};const P=async(n,s,e,i,r,a,f=false)=>{if(!e&&!i){return}const l=y(n,e||i,r);if(e&&Math.abs(l.scrollAmount)<4){T(s);if(a&&e!==null){x(e,k);g(s,e,(()=>k=0))}return}u(n,s,true,l.inputSafeY,f);T(s);c((()=>n.click()));if(a&&e){k=l.scrollPadding;x(e,k)}if(typeof window!=="undefined"){let c;const i=async()=>{if(c!==undefined){clearTimeout(c)}window.removeEventListener("ionKeyboardDidShow",r);window.removeEventListener("ionKeyboardDidShow",i);if(e){await o(e,0,l.scrollAmount,l.scrollDuration)}u(n,s,false,l.inputSafeY);T(s);if(a){g(s,e,(()=>k=0))}};const r=()=>{window.removeEventListener("ionKeyboardDidShow",r);window.addEventListener("ionKeyboardDidShow",i)};if(e){const o=await t(e);const n=o.scrollHeight-o.clientHeight;if(l.scrollAmount>n-o.scrollTop){if(s.type==="password"){l.scrollAmount+=w;window.addEventListener("ionKeyboardDidShow",r)}else{window.addEventListener("ionKeyboardDidShow",i)}c=setTimeout(i,1e3);return}}i()}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const $=true;const A=async(t,o)=>{const s=document;const e=o==="ios";const c=o==="android";const r=t.getNumber("keyboardHeight",290);const f=t.getBoolean("scrollAssist",true);const u=t.getBoolean("hideCaretOnScroll",e);const l=t.getBoolean("inputBlurring",e);const d=t.getBoolean("scrollPadding",true);const p=Array.from(s.querySelectorAll("ion-input, ion-textarea"));const w=new WeakMap;const S=new WeakMap;const b=await a.getResizeMode();const y=async t=>{await new Promise((o=>i(t,o)));const o=t.shadowRoot||t;const s=o.querySelector("input")||o.querySelector("textarea");const e=n(t);const a=!e?t.closest("ion-footer"):null;if(!s){return}if(!!e&&u&&!w.has(t)){const o=m(t,s,e);w.set(t,o)}const l=s.type==="date"||s.type==="datetime-local";if(!l&&(!!e||!!a)&&f&&!S.has(t)){const o=j(t,s,e,a,r,d,b,c);S.set(t,o)}};const M=t=>{if(u){const o=w.get(t);if(o){o()}w.delete(t)}if(f){const o=S.get(t);if(o){o()}S.delete(t)}};if(l&&$){h()}for(const t of p){y(t)}s.addEventListener("ionInputDidLoad",(t=>{y(t.detail)}));s.addEventListener("ionInputDidUnload",(t=>{M(t.detail)}))};export{A as startInputShims};
//# sourceMappingURL=p-8704fc2c.js.map