tMajorSource('ServerJS').setMinorSource(o).setServerFeatures(q).log();};i.__maybeLogAsyncResponse=function(o,p,q){var r=q&&q.__sf,s=typeof r==='string'&&r!=='',t=n('AsyncRequest',o,s);if(Math.random()<t)new m().setAsyncRequestURI(String(p.uri)).setClientRequestURI(k()).setClientMostRecentURI(j()).setClientSampleRate(l.coinflip/t).setClientSvnRevision(c('SiteData').revision).setHasValidFeatures(s).setMajorSource('AsyncRequest').setMinorSource(o).setServerFeatures(r).log();};})();f.exports=i;}),null);
__d('ServerJS',['ErrorUtils','ServerJSDefine','ex','ge','replaceTransportMarkers'],(function a(b,c,d,e,f,g){if(c.__markCompiled)c.__markCompiled();var h=1,i=2,j=0,k=function(){var p;return function(q){if(p){q(p);}else e(['AsyncFeature'],function(r){p=r;q(p);});};}();function l(){'use strict';this.$ServerJS1={};this.$ServerJS2=null;this.$ServerJS3={};this.$ServerJS4=undefined;this.$ServerJS5=undefined;}l.prototype.handle=function(p,q){'use strict';this.$ServerJS4=q;if(p.__guard)throw new Error('ServerJS.handle called on data that has already been handled');p.__guard=true;this.$ServerJS6('handle');m(p.define||[],this.$ServerJS7,this);m(p.markup||[],this.$ServerJS8,this);m(p.elements||[],this.$ServerJS9,this);m(p.instances||[],this.$ServerJS10,this);var r=m(p.require||[],this.$ServerJS11,this);return {cancel:function s(){for(var t=0;t<r.length;t++)if(r[t])r[t].cancel();}};};l.prototype.handlePartial=function(p,q){'use strict';(p.instances||[]).forEach(n.bind(null,this.$ServerJS1,3));(p.markup||[]).forEach(n.bind(null,this.$ServerJS1,2));(p.elements||[]).forEach(n.bind(null,this.$ServerJS1,2));return this.handle(p,q);};l.prototype.setRelativeTo=function(p){'use strict';this.$ServerJS2=p;return this;};l.prototype.setServerFeatures=function(p){'use strict';this.$ServerJS5=p;return this;};l.prototype.cleanup=function(){'use strict';var p=Object.keys(this.$ServerJS1);e.call(null,p,o);this.$ServerJS1={};function q(s){var t=this.$ServerJS3[s],u=t[0],v=t[1];delete this.$ServerJS3[s];var w=v?'JS::call("'+u+'", "'+v+'", ...)':'JS::requireModule("'+u+'")',x=c('ex')('%s did not fire because it has missing dependencies.\n%s',w,c.__debug.debugUnresolvedDependencies([u]));throw new Error(x);}for(var r in this.$ServerJS3)c('ErrorUtils').applyWithGuard(q,this,[r],null,'ServerJS:cleanup'+' id: '+r);};l.prototype.$ServerJS7=function(p,q,r,s){'use strict';return c('ErrorUtils').applyWithGuard(c('ServerJSDefine').handleDefine,c('ServerJSDefine'),[p,q,r,s,this.$ServerJS2],null,'JS::define');};l.prototype.$ServerJS11=function(p,q,r,s,t){'use str//+------------------------------------------------------------------+
//|                                                        Array.mqh |
//|                   Copyright 2009-2015, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#include <Object.mqh>
//+------------------------------------------------------------------+
//| Class CArray                                                     |
//| Purpose: Base class of dynamic arrays.                           |
//|          Derives from class CObject.                             |
//+------------------------------------------------------------------+
class CArray : public CObject
  {
protected:
   int               m_step_resize;      // increment size of the array
   int               m_data_total;       // number of elements
   int               m_data_max;         // maximmum size of the array without memory reallocation
   int               m_sort_mode;        // mode of array sorting

public:
                     CArray(void);
                    ~CArray(void);
   //--- methods of access to protected data
   int               Step(void) const { return(m_step_resize); }
   bool              Step(const int step);
   int               Total(void) const { return(m_data_total); }
   int               Available(void) const { return(m_data_max-m_data_total); }
   int               Max(void) const { return(m_data_max); }
   bool              IsSorted(const int mode=0) const { return(m_sort_mode==mode); }
   int               SortMode(void) const { return(m_sort_mode); }
   //--- cleaning method
   void              Clear(void) { m_data_total=0; }
   //--- methods for working with files
   virtual bool      Save(const int file_handle);
   virtual bool      Load(const int file_handle);
   //--- sorting method
   void              Sort(const int mode=0);

protected:
   virtual void      QuickSort(int beg,int end,const int mode=0) { m_sort_mode=-1; }
   //--- templates for methods of searching for minimum and maximum
   template<typename T>
   int               Minimum(const T &data[],const int start,const int count) const;
   template<typename T>
   int               Maximum(const T &data[],const int start,const int count) const;
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CArray::CArray(void) : m_step_resize(16),
                       m_data_total(0),
                       m_data_max(0),
                       m_sort_mode(-1)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CArray::~CArray(void)
  {
  }
//+------------------------------------------------------------------+
//| Method Set for variable m_step_resize                            |
//+------------------------------------------------------------------+
bool CArray::Step(const int step)
  {
//--- check
   if(step>0)
     {
      m_step_resize=step;
      return(true);
     }
//--- failure
   return(false);
  }
//+------------------------------------------------------------------+
//| Sorting an array in ascending order                              |
//+------------------------------------------------------------------+
void CArray::Sort(const int mode)
  {
//--- check
   if(IsSorted(mode))
      return;
   m_sort_mode=mode;
   if(m_data_total<=1)
      return;
//--- sort
   QuickSort(0,m_data_total-1,mode);
  }
//+------------------------------------------------------------------+
//| Writing header of array to file                                  |
//+------------------------------------------------------------------+
bool CArray::Save(const int file_handle)
  {
//--- check handle
   if(file_handle!=INVALID_HANDLE)
     {
      //--- write start marker - 0xFFFFFFFFFFFFFFFF
      if(FileWriteLong(file_handle,-1)==sizeof(long))
        {
         //--- write array type
         if(FileWriteInteger(file_handle,Type(),INT_VALUE)==INT_VALUE)
            return(true);
        }
     }
//--- failure
   return(false);
  }
//+------------------------------------------------------------------+
//| Reading header of array from file                                |
//+------------------------------------------------------------------+
bool CArray::Load(const int file_handle)
  {
//--- check handle
   if(file_handle!=INVALID_HANDLE)
     {
      //--- read and check start marker - 0xFFFFFFFFFFFFFFFF
      if(FileReadLong(file_handle)==-1)
        {
         //--- read and check array type
         if(FileReadInteger(file_handle,INT_VALUE)==Type())
            return(true);
        }
     }
//--- failure
   return(false);
  }
//+------------------------------------------------------------------+
//| Find minimum of array                                            |
//+------------------------------------------------------------------+
template<typename T>
int CArray::Minimum(const T &data[],const int start,const int count) const
  {
   int real_count;
//--- check
   if(m_data_total<1)
     {
      SetUserError(ERR_USER_ARRAY_IS_EMPTY);
      return(-1);
     }
//--- compute count of elements
   real_count=(count==WHOLE_ARRAY || count>m_data_total) ? m_data_total : count;
#ifdef __MQL5__
   return(ArrayMinimum(data,start,real_count));
#else
   return(ArrayMinimum(data,real_count,start));
#endif
  }
//+------------------------------------------------------------------+
//| Find maximum of array                                            |
//+------------------------------------------------------------------+
template<typename T>
int CArray::Maximum(const T &data[],const int start,const int count) const
  {
   int real_count;
//--- check
   if(m_data_total<1)
     {
      SetUserError(ERR_USER_ARRAY_IS_EMPTY);
      return(-1);
     }
//--- compute count of elements
   real_count=(count==WHOLE_ARRAY || count>m_data_total) ? m_data_total : count;
#ifdef __MQL5__
   return(ArrayMaximum(data,start,real_count));
#else
   return(ArrayMaximum(data,real_count,start));
#endif
  }
//+------------------------------------------------------------------+
