text: (function(){var t=window.BX;if(t["UpdateStepperRegister"])return;var e=new(function(){var e=function(){this.length=0;this.items={};this.order=[];this.state="ready";this.finish=t.delegate(this.finish,this);this.send=t.delegate(this.send,this);this.onSuccess=t.delegate(this.onSuccess,this);this.onFailure=t.delegate(this.onFailure,this)};e.prototype={getQueue:function(e){e+="";return t.util.array_search(e,this.order)},removeItem:function(e){e+="";var s,i;if(typeof this.items[e]!=="undefined"){s=this.items[e];i=this.getQueue(e);this.pointer-=this.pointer>=i?1:0;delete this.items[e];this.order=t.util.deleteFromArray(this.order,i);this.length=this.order.length}return s},getItem:function(t){t+="";return this.items[t]},hasItem:function(t){t+="";return typeof this.items[t]!=="undefined"},setItem:function(e,s){e+="";if(typeof s!=="undefined"){if(typeof this.items[e]==="undefined"){this.order.push(e);this.length=this.order.length}this.items[e]=s;t.addCustomEvent(s,"onFinish",this.finish)}this.exec();return s},getFirst:function(){var t,e=null;for(var s=0;s<this.order.length;s++){t=this.order[s];if(!!t&&this.hasItem(t)){e=this.getItem(t);break}}return e},timeout:0,exec:function(){if(this.timeout>0)clearTimeout(this.timeout);if(this.length>0)this.timeout=setTimeout(t.proxy(this.send,this),3e4)},send:function(){var e=[],s;if(this.length>0){t.onCustomEvent(this,"onPrepare",[e,this])}if(e.length>0){t.ajax({method:"POST",dataType:"json",data:{stepper:e},url:"/bitrix/tools/update.php?action=stepper",onsuccess:this.onSuccess,onfailure:this.onFailure})}},onSuccess:function(e){t.onCustomEvent(this,"onSuccess",[e,this]);this.exec()},onFailure:function(e){if(e==="processing")e="Incorrect server response.";t.onCustomEvent(this,"onFailure",[e,this])},finish:function(t){this.removeItem(t)}};return e}()),s=function(){var s=function(s,i){this.id=s;this.data=i;this.nodes={container:null,bar:null,steps:null,count:null};this.onPrepare=t.delegate(this.onPrepare,this);this.onSuccess=t.delegate(this.onSuccess,this);this.onFailure=t.delegate(this.onFailure,this);t.defer_proxy(this.bind,this)();e.setItem(this.id,this);t.addCustomEvent(e,"onPrepare",this.onPrepare);t.addCustomEvent(e,"onSuccess",this.onSuccess);t.addCustomEvent(e,"onFailure",this.onFailure)};s.prototype={show:function(e,s){var i=100;if(s>0)i=parseInt(e*100/s);if(t(this.nodes.bar))this.nodes.bar.style.width=i+"%";if(t(this.nodes.steps))this.nodes.steps.innerHTML=e;if(t(this.nodes.count))this.nodes.count.innerHTML=s},bindSteps:0,bind:function(){if(this.bindSteps>100)return;this.bindSteps++;if(t(this.id+"-steps")){this.nodes.container=t(this.id+"-container");this.nodes.bar=t(this.id+"-bar");this.nodes.steps=t(this.id+"-steps");this.nodes.count=t(this.id+"-count");this.nodes.error=t(this.id+"-error")}else{t.defer_proxy(this.bind,this)()}},hide:function(){if(t(this.nodes.container)){t.addClass(this.nodes.container,"main-stepper-hide");t.removeClass(this.nodes.container,"main-stepper-show")}},finish:function(){t.removeCustomEvent(e,"onPrepare",this.onPrepare);t.removeCustomEvent(e,"onSuccess",this.onSuccess);t.removeCustomEvent(e,"onFailure",this.onFailure);t.onCustomEvent(this,"onFinish",[this.id,this])},onPrepare:function(t){for(var e=0;e<this.data.length;e++){if(parseInt(this.data[e]["steps"])<parseInt(this.data[e]["count"])){t.push({moduleId:this.data[e]["moduleId"],class:this.data[e]["class"]})}}},onSuccess:function(e){if(t.type.isPlainObject(e)&&e["status"]==="error"){this.onFailure(e["message"]);return}var s=[],i=[],n,o=0,r=0;for(var h=0;h<this.data.length;h++){i.push({moduleId:this.data[h]["moduleId"],class:this.data[h]["class"],steps:parseInt(this.data[h]["steps"]),count:parseInt(this.data[h]["count"])})}if(t.type.isArray(e)){for(h=0;h<e.length;h++){for(n=0;n<i.length;n++){if(i[n]["moduleId"]===e[h]["moduleId"]&&i[n]["class"]===e[h]["class"]){s.push({moduleId:e[h]["moduleId"],class:e[h]["class"],steps:parseInt(e[h]["steps"]),count:parseInt(e[h]["count"])});o+=parseInt(e[h]["steps"]);r+=parseInt(e[h]["count"]);i=t.util.deleteFromArray(i,n);break}}if(i.length<=0)break}}for(n=0;n<i.length;n++){o+=i[n]["count"];r+=i[n]["count"];s.push({moduleId:i[n]["moduleId"],class:i[n]["class"],steps:i[n]["count"],count:i[n]["count"]})}this.data=s;if(o<r&&r>0){this.show(o,r);t.onCustomEvent(window,"onStepperProgress",[this])}else{this.hide();this.finish();t.onCustomEvent(window,"onStepperHasBeenFinished",[this])}},onFailure:function(e){this.showError(e);this.finish();t.onCustomEvent(window,"onStepperHasBeenFailed",[this])},showError:function(e){if(t(this.nodes.error))this.nodes.error.innerHTML=e;if(this.nodes.container)t.addClass(this.nodes.container,"main-stepper-error")}};return s}();t.UpdateStepperRegister=function(t,e){new s(t,e)}})();