import{__awaiter,__generator}from"tslib";import{e as waitAfterIdleCallback}from"./helpers-008ae2b8.js";var stopEventBubbling=function(n){if(n){n.preventDefault();n.stopPropagation()}};var getInputTarget=function(n){return n.target};var getNativeInputValue=function(n){var t;return((t=n.nativeInput)===null||t===void 0?void 0:t.value)||""};var getUpcomingValue=function(n,t){var i,e;var a=((i=n.nativeInput)===null||i===void 0?void 0:i.value)||"";var u=(e=t.target)===null||e===void 0?void 0:e.selectionStart;return a.slice(0,u)+t.key+a.slice(u+Math.abs(0))};var inputSetBlur=function(n){if(n.nativeInput){n.nativeInput.blur()}};var inputListenOnClick=function(n,t){if((n.disabled||n.readonly)&&t.target&&t.target===n.el){stopEventBubbling(t)}};var inputSetFocus=function(n){return __awaiter(void 0,void 0,void 0,(function(){var t;return __generator(this,(function(i){switch(i.label){case 0:return[4,waitAfterIdleCallback()];case 1:i.sent();(t=n===null||n===void 0?void 0:n.nativeInput)===null||t===void 0?void 0:t.focus();return[2]}}))}))};var inputHandleHostClick=function(n,t){if(n.disabled||n.readonly){stopEventBubbling(t)}};var inputHandleClick=function(n,t){if(!n.disabled&&!n.readonly&&n.balClick){n.balClick.emit(t)}};var inputHandleFocus=function(n,t){n.focused=true;n.inputValue=n.value;if(!n.disabled&&n.balFocus){n.balFocus.emit(t)}};var inputHandleReset=function(n,t,i){if(t===void 0){t=undefined}n.value=t;n.inputValue=n.value;clearTimeout(i);i=setTimeout((function(){if(n.nativeInput){n.nativeInput.value=n.value}}))};var inputHandleBlur=function(n,t){n.focused=false;if(!n.disabled&&n.balBlur){n.balBlur.emit(t)}};var inputHandleChange=function(n){if(n.value!==n.inputValue){n.value=n.inputValue;n.balChange.emit(n.value)}};export{inputHandleHostClick as a,inputListenOnClick as b,inputSetFocus as c,inputSetBlur as d,inputHandleBlur as e,inputHandleChange as f,getInputTarget as g,inputHandleClick as h,inputHandleFocus as i,inputHandleReset as j,getUpcomingValue as k,getNativeInputValue as l,stopEventBubbling as s};