!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","react","./constants","./FormElementOuter","./keyboard","./utils"],e)}(function(n,e){"use strict";var t="object"==typeof module&&"object"==typeof module.exports;Object.defineProperty(e,"__esModule",{value:!0});var R=n("tslib"),S=R.__importDefault(n("react")),_=n("./constants"),C=R.__importDefault(n("./FormElementOuter")),x=n("./keyboard"),D=n("./utils"),o=S.default.lazy(function(){return t?Promise.resolve().then(function(){return R.__importStar(n("./components/NumberRangeSlider"))}):new Promise(function(e,t){n(["./components/NumberRangeSlider"],e,t)}).then(R.__importStar)});e.renderNumberRangeSlider=function(e,t){return S.default.createElement(S.default.Suspense,{fallback:null},S.default.createElement(o,{component:e,element:t}))},e.renderNumber=function(n,u){var t=n.props.name,a=n.props.host,l=(f=(M=u.value,N=u.format,N=null==(N=D.isNumberRef(M)?M.format:N)?{}:N)).precision;"number"==typeof l&&0*l==0||(l=3);var i=Math.pow(10,-1*l),s=Math.round(f.step/i)*i;"number"==typeof s&&0*s<s||(s=void 0);var m=Math.floor(f.lowerBound/i)*i;"number"==typeof m&&0*m==0||(m=void 0);var p=Math.ceil(f.upperBound/i)*i;"number"==typeof p&&0*p==0||(p=void 0),void 0!==m&&void 0!==p&&p<=m&&(p=m=void 0);var e=[_.CssClasses.NUMERIC,D.makeSafeClassName(t)],o=!1;u.type===_.FormElementTypes.NUMBERSLIDER&&(e.push(_.CssClasses.SLIDER),o=!0,void 0===s&&(s=Math.max(1,i)),void 0===m&&(m=0),void 0===p&&(p=100)),void 0!==s&&e.push(_.CssClasses.STEPPER);var f={precision:l,step:s,lowerBound:m,upperBound:p},d={useGrouping:!0,minimumFractionDigits:0<l?l:0,maximumFractionDigits:0<l?l:0};function r(e){var t,n,o;if(e=function(e){if("string"==typeof e){if(e.length<1)return;e=Number(e)}if("number"==typeof e&&0*e==0)return void 0!==p&&p<e&&(e=p),void 0!==m&&e<m&&(e=m),Math.round(e/i)*i}(e),u.type===_.FormElementTypes.NUMBERSLIDER&&void 0===e&&void 0!==m&&void 0!==p&&((o=((t=(m+p)/2)-m)/(n=s||i))%1==0?e=t:(o=Math.ceil(o),(r=m+o*n)<=p&&(e=r))),void 0===e)return u.value=void 0,"";u.value={refValueType:"number",format:f,display:a.formatNumber(e,d),numeric:e};var r=20<(r=l)?20:r;return e.toFixed(r=r<0?0:r)}var c,v=null,b=null,y=(c=u.value,D.isNumberRef(c)&&(c=c.numeric),r("number"==typeof(c=D.isString(c)?a.coerceNumber(c):c)?c:void 0));function h(e){return e=r(e),v.value=b.value=e,E=v.value,y!==e&&(y=e,a.post("changed",{name:t,value:u.value}),1)}var E=void 0;function g(){var e=v.value;E!==e&&h(e)}var M=a.renderText(u.prompt),N=a.renderText(u.tooltip);return S.default.createElement(C.default,{className:e.join(" "),component:n,element:u,errorClassName:_.CssClasses.ERROR,htmlElementType:"label",ref:function(e){null!==e&&null===e.querySelector("*:focus")&&(v.value=b.value=y,E=v.value,a.renderFocus(o?v:b,t))}},S.default.createElement("input",R.__assign({placeholder:M,title:N},{type:"range",disabled:!n.enabled,min:m,max:p,step:s,onMouseMove:g,onMouseDown:g,onChange:g,onInput:g,ref:function(e){v=e}})),S.default.createElement("input",R.__assign({placeholder:M,title:N},{type:"number",disabled:!n.enabled,min:m,max:p,step:s,onKeyDown:function(e){var t=x.getKeyString(e);if("enter"===t&&h(b.value))return b.select(),e.preventDefault(),e.stopPropagation(),!1;"escape"===t&&(v.value=b.value=y,b.select()),n.autoInput=!1},onFocus:function(){b.select()},onMouseDown:function(){n.autoInput=!0},onChange:function(){n.autoInput&&(h(b.value),b.select())},onBlur:function(){h(b.value)},ref:function(e){b=e}})))}});