(function(d){"function"===typeof define&&define.amd?define(["jquery","./core","./widget","./button"],d):d(jQuery)})(function(d){function e(a){return function(){var b=this.element.val();a.apply(this,arguments);this._refresh();b!==this.element.val()&&this._trigger("change")}}return d.widget("ui.spinner",{version:"1.11.4",defaultElement:"<input>",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,
page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max);this._setOption("min",this.options.min);this._setOption("step",this.options.step);""!==this.value()&&this._value(this.element.val(),!0);this._draw();this._on(this._events);this._refresh();this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var a={},b=this.element;d.each(["min","max","step"],function(c,d){var e=b.attr(d);
void 0!==e&&e.length&&(a[d]=e)});return a},_events:{keydown:function(a){this._start(a)&&this._keydown(a)&&a.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(a){this.cancelBlur?delete this.cancelBlur:(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",a))},mousewheel:function(a,b){if(b){if(!this.spinning&&!this._start(a))return!1;this._spin((0<b?1:-1)*this.options.step,a);clearTimeout(this.mousewheelTimer);this.mousewheelTimer=
this._delay(function(){this.spinning&&this._stop(a)},100);a.preventDefault()}},"mousedown .ui-spinner-button":function(a){function b(){this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=c,this._delay(function(){this.previous=c}))}var c;c=this.element[0]===this.document[0].activeElement?this.previous:this.element.val();a.preventDefault();b.call(this);this.cancelBlur=!0;this._delay(function(){delete this.cancelBlur;b.call(this)});!1!==this._start(a)&&this._repeat(null,
d(a.currentTarget).hasClass("ui-spinner-up")?1:-1,a)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(a){if(d(a.currentTarget).hasClass("ui-state-active")){if(!1===this._start(a))return!1;this._repeat(null,d(a.currentTarget).hasClass("ui-spinner-up")?1:-1,a)}},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var a=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());
this.element.attr("role","spinbutton");this.buttons=a.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all");this.buttons.height()>Math.ceil(.5*a.height())&&0<a.height()&&a.height(a.height());this.options.disabled&&this.disable()},_keydown:function(a){var b=this.options,c=d.ui.keyCode;switch(a.keyCode){case c.UP:return this._repeat(null,1,a),!0;case c.DOWN:return this._repeat(null,-1,a),!0;case c.PAGE_UP:return this._repeat(null,b.page,a),!0;case c.PAGE_DOWN:return this._repeat(null,
-b.page,a),!0}return!1},_uiSpinnerHtml:function(){return"<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"},_buttonHtml:function(){return"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'><span class='ui-icon "+this.options.icons.up+"'>&#9650;</span></a><a class='ui-spinner-button ui-spinner-down ui-corner-br'><span class='ui-icon "+this.options.icons.down+"'>&#9660;</span></a>"},_start:function(a){if(!this.spinning&&!1===this._trigger("start",a))return!1;this.counter||
(this.counter=1);return this.spinning=!0},_repeat:function(a,b,c){a=a||500;clearTimeout(this.timer);this.timer=this._delay(function(){this._repeat(40,b,c)},a);this._spin(b*this.options.step,c)},_spin:function(a,b){var c=this.value()||0;this.counter||(this.counter=1);c=this._adjustValue(c+a*this._increment(this.counter));this.spinning&&!1===this._trigger("spin",b,{value:c})||(this._value(c),this.counter++)},_increment:function(a){var b=this.options.incremental;return b?d.isFunction(b)?b(a):Math.floor(a*
a*a/5E4-a*a/500+17*a/200+1):1},_precision:function(){var a=this._precisionOf(this.options.step);null!==this.options.min&&(a=Math.max(a,this._precisionOf(this.options.min)));return a},_precisionOf:function(a){a=a.toString();var b=a.indexOf(".");return-1===b?0:a.length-b-1},_adjustValue:function(a){var b,c=this.options;b=null!==c.min?c.min:0;a=Math.round((a-b)/c.step)*c.step;a=b+a;a=parseFloat(a.toFixed(this._precision()));return null!==c.max&&a>c.max?c.max:null!==c.min&&a<c.min?c.min:a},_stop:function(a){this.spinning&&
(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",a))},_setOption:function(a,b){if("culture"===a||"numberFormat"===a){var c=this._parse(this.element.val());this.options[a]=b;this.element.val(this._format(c))}else"max"!==a&&"min"!==a&&"step"!==a||"string"!==typeof b||(b=this._parse(b)),"icons"===a&&(this.buttons.first().find(".ui-icon").removeClass(this.options.icons.up).addClass(b.up),this.buttons.last().find(".ui-icon").removeClass(this.options.icons.down).addClass(b.down)),
this._super(a,b),"disabled"===a&&(this.widget().toggleClass("ui-state-disabled",!!b),this.element.prop("disabled",!!b),this.buttons.button(b?"disable":"enable"))},_setOptions:e(function(a){this._super(a)}),_parse:function(a){"string"===typeof a&&""!==a&&(a=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(a,10,this.options.culture):+a);return""===a||isNaN(a)?null:a},_format:function(a){return""===a?"":window.Globalize&&this.options.numberFormat?Globalize.format(a,this.options.numberFormat,
this.options.culture):a},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var a=this.value();return null===a?!1:a===this._adjustValue(a)},_value:function(a,b){var c;""!==a&&(c=this._parse(a),null!==c&&(b||(c=this._adjustValue(c)),a=this._format(c)));this.element.val(a);this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");
this.uiSpinner.replaceWith(this.element)},stepUp:e(function(a){this._stepUp(a)}),_stepUp:function(a){this._start()&&(this._spin((a||1)*this.options.step),this._stop())},stepDown:e(function(a){this._stepDown(a)}),_stepDown:function(a){this._start()&&(this._spin((a||1)*-this.options.step),this._stop())},pageUp:e(function(a){this._stepUp((a||1)*this.options.page)}),pageDown:e(function(a){this._stepDown((a||1)*this.options.page)}),value:function(a){if(!arguments.length)return this._parse(this.element.val());
e(this._value).call(this,a)},widget:function(){return this.uiSpinner}})});