!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","react","../constants","../FormElementOuter","../numberSliderUtilities","react-range","../utils","../../BrowserUtils","../common"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var F,M=e("tslib"),S=M.__importStar(e("react")),I=e("../constants"),R=M.__importDefault(e("../FormElementOuter")),T=e("../numberSliderUtilities"),B=e("react-range"),D=e("../utils"),j=e("../../BrowserUtils"),O=e("../common");t.default=function(e){var a=e.component,t=e.element,n=S.useMemo(function(){return T.getProcessedNumberFormat(t.format)},[]),r=S.useState(S.useMemo(function(){return t.value=T.getInitialNumberSliderValues(t.value,n),t.value},[])),o=r[0],i=r[1],e=S.useState(t.value),u=e[0],s=e[1],r=a.props,l=r.host,c=r.name,d=S.useCallback(function(e){e instanceof B.Range&&(e=e.thumbRefs[0].current),O.renderFocus(e,c,l)},[]),m=n.lowerBound,f=n.upperBound,e=n.precision,p=t.showMinMaxLabels,v=t.manualEntry,g=n.step,x=t.showTickMarks,x=0<g&&x;0===g&&(g=1/Math.pow(10,e));function y(e){e=_(e),A(e),(Array.isArray(F)||e[0]===m&&e[1]===f)&&(!Array.isArray(F)||e[0]===F[0]&&e[1]===F[1])||(t.value=F=e,l.post("changed",{name:c,value:t.value}))}function b(e){a.autoInput=!0}function h(e){return e.target.select()}function _(e){return[e[0]<m?m:e[0]>f?f:e[0],e[1]>f?f:e[1]<m?m:e[1]].sort(function(e,t){return e-t})}function E(e,t,n,r,a,o){return S.default.createElement("div",{style:{position:"absolute",top:t,color:a=void 0===a?"#fff":a,fontWeight:"bold",fontSize:"14px",fontFamily:"Arial,Helvetica Neue,Helvetica,sans-serif",padding:"4px",borderRadius:"5px",backgroundColor:o=void 0===o?"#197dc8":o,left:n,right:r,whiteSpace:"nowrap"}},e)}var k=!a.enabled,N={currency:n.currency,customDisplayFormat:n.customDisplayFormat,format:n.displayFormat,fractionalDigits:e,locale:l.deriveLocale()},r=l.renderText(t.tooltip),e=[t.type,D.makeSafeClassName(c)],w=S.useMemo(function(){return D.throttle(function(e){l.post("dragged",{name:c,value:e})})},[]),C=function(e,t){var n=o.slice(),e=""!==e?Number(e):NaN;isNaN(e)?A(n):(0===t?(e=e<m?m:e)>n[1]&&(e=n[1]):(e=f<e?f:e)<n[0]&&(e=n[0]),n[t]=e,y(n))},A=function(e){i(e),s(e)};return S.default.createElement(R.default,{className:e.join(" "),component:a,element:t,errorClassName:I.CssClasses.ERROR},!j.isIE()&&S.default.createElement("div",{className:"slider-container",title:r},S.default.createElement(B.Range,{draggableTrack:!0,step:g,min:m,max:f,values:o,onChange:function(e){e=_(e),A(e),Array.isArray(t.value)&&e[0]===t.value[0]&&e[1]===t.value[1]||(t.value=e,w(t.value))},onFinalChange:y,renderMark:function(e){var t=e.props,n=e.index,e=m+n*g,n=f<e,e=e>o[0]&&e<o[1]?"#197dc8":"#ccc";return x&&!n&&S.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"16px",width:"2px",backgroundColor:e})}))},renderTrack:function(e){var t=e.props,e=e.children;return S.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"6px",margin:"50px 0px 24px",width:"100%",background:B.getTrackBackground({values:o,colors:["#ccc","#197dc8","#ccc"],min:m,max:f,rtl:!1})})}),!1!==p&&E(l.formatNumber(m,N,!0),"20px","-12px",void 0,"#333","#fff"),!1!==p&&E(l.formatNumber(f,N,!0),"20px",void 0,"-12px","#333","#fff"),e)},renderThumb:function(e){var t=e.props,n=e.value,r=e.index,a=f-m,e=n-m,n=e<a/10?"0":"auto",e=9*a/10<e?"0":"auto";return S.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"24px",width:"24px",borderRadius:"12px",backgroundColor:"#197dc8",display:"flex",justifyContent:"center",alignItems:"center",boxShadow:"0px 2px 4px #AAA",outline:"none"})}),E(l.formatNumber(o[r],N,!0),"-32px",n,e))},disabled:k,ref:d})),!1!==v||j.isIE()?S.default.createElement("div",{className:"inputs"},u.map(function(e,r){return S.default.createElement("span",null,0===r?l.renderText("@common-start"):l.renderText("@common-end"),S.default.createElement("input",{key:r,type:"number",disabled:k,min:0===r?m:o[0],max:0===r?o[1]:f,step:g,title:e+"",value:e,onBlur:function(e){C(e.target.value,r)},onChange:function(e){return t=e,n=r,(e=u.slice())[n]=t.target.value,s(e),void(a.autoInput&&C(t.target.value,n));var t,n},onKeyDown:function(e){return t=r,(e=e).stopPropagation(),a.autoInput=!1,void("Enter"===e.key?C(u[t]+"",t):"Escape"===e.key&&A(o.slice()));var t},onMouseDown:b,onFocus:h,ref:0===r&&j.isIE()?d:void 0}))})):null)}});