import{__awaiter,__generator}from"tslib";import{b as waitAfterIdleCallback}from"./helpers-BNj87EbG.js";var stopEventBubbling=function(n){if(n){n.preventDefault();n.stopPropagation()}};var getInputTarget=function(n){return n.target};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)}};var isEmptyValue=function(n){return n===""||n===undefined||n===null||Array.isArray(n)&&!n.length||typeof n==="number"&&isNaN(n)};var parseValue=function(n){return isEmptyValue(n)?undefined:n};var hasValueChanged=function(n,t){return parseValue(n)!==parseValue(t)};export{inputHandleFocus as a,inputHandleBlur as b,inputSetFocus as c,inputSetBlur as d,inputHandleChange as e,inputHandleClick as f,getInputTarget as g,inputListenOnClick as h,inputHandleHostClick as i,inputHandleReset as j,getUpcomingValue as k,hasValueChanged as l,stopEventBubbling as s};