helper functions
345017
function(recursive_trans, ts, pid, kthread,
                                         trans, args) {

      var recursive_slice = recursive_trans[1].slice;
      var orig_slice = recursive_trans[0].slice;
      recursive_slice.duration = ts - recursive_slice.start;
      trans.slice = recursive_slice;

      if (trans.is_reply_transaction) {
        /* Case one:
         * This transaction is finally the reply of the recursion.
         */
        orig_slice.duration = ts - orig_slice.start;
        this.addSyncTransNeedingCompletion(trans.transaction_key,
             recursive_trans);

        if (isReplyToOrigin(recursive_trans[0], trans))
          this.removeRecursiveTransaction(pid);
      } else {
        /**
         *  Case two:
         *  This transaction is more recursive calls.
         *  This is a nested call within an already started transaction,
         *  it can either be a async or a normal sync transaction.
         */
        var slice = kthread.thread.sliceGroup.pushCompleteSlice('binder',
            '' , ts, .03, 0,
            0, args);

        trans.slice = slice;
        this.addTransactionWaitingForRecv(trans.transaction_key, trans);
      }
      return true;
    }
775187
function toWindow(key, val, exclude) {
    /* istanbul ignore if */
    if (!is_1.isBrowser())
        return;
    exclude = toArray(exclude);
    var _keys, i;
    // key/val was passed.
    if (is_1.isString(key)) {
        if (!is_1.isPlainObject(val)) {
            window[key] = val;
        }
        else {
            var obj = {};
            _keys = array_1.keys(val);
            i = _keys.length;
            while (i--) {
                if (!array_1.contains(exclude, _keys[i]))
                    obj[_keys[i]] = val[_keys[i]];
            }
            window[key] = obj;
        }
    }
    // object passed to key.
    else if (is_1.isPlainObject(key)) {
        _keys = array_1.keys(key);
        i = _keys.length;
        while (i--) {
            if (!array_1.contains(exclude, _keys[i]))
                window[_keys[i]] = key[_keys[i]];
        }
    }
}
590095
function(command, argument) {
		/// <summary>
		/// Return the validations rules for the first selected element.
		/// </summary>
		/// <param name="command" type="String">
		/// Can be either "add" or "remove".
		/// </param>
		/// <param name="argument" type="">
		/// A list of rules to add or remove.
		/// </param>

		var element = this[0];
		
		if (command) {
			var settings = $.data(element.form, 'validator').settings;
			var staticRules = settings.rules;
			var existingRules = $.validator.staticRules(element);
			switch(command) {
			case "add":
				$.extend(existingRules, $.validator.normalizeRule(argument));
				staticRules[element.name] = existingRules;
				if (argument.messages)
					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
				break;
			case "remove":
				if (!argument) {
					delete staticRules[element.name];
					return existingRules;
				}
				var filtered = {};
				$.each(argument.split(/\s/), function(index, method) {
					filtered[method] = existingRules[method];
					delete existingRules[method];
				});
				return filtered;
			}
		}
		
		var data = $.validator.normalizeRules(
		$.extend(
			{},
			$.validator.metadataRules(element),
			$.validator.classRules(element),
			$.validator.attributeRules(element),
			$.validator.staticRules(element)
		), element);
		
		// make sure required is at front
		if (data.required) {
			var param = data.required;
			delete data.required;
			data = $.extend({required: param}, data);
		}
		
		return data;
	}
1105737
function exec (ctx, scope, data) {
  console.log('exec', ctx, scope, data)
  var fn = getFunction(ctx, scope, data[0])
  var elements = data.slice(1)
  var params = elements.map(function (p) {
    return Array.isArray(p) ? exec(ctx, scope, p)
      : (p[0] === '$') ? ctx[p] : p
  }).filter(function (p) { return p !== VAR })
  return fn.apply(null, params)
}
459197
function $$(instance, clazz, ctor, args) {
                if (DomImpl_ == SELF)
                    throw Error('');

                instance = DomImpl_.apply(undefined, args);
                ria.__SYNTAX && ria.__SYNTAX.checkReturn(ria.dom.Dom, instance);
                return instance;
            }
851307
function(one, two) {
        if (one.tag != two.tag) {
            return false;
        } else if (one.text.trim() != two.text.trim()) {
            return false;
        } else if (one._children.length != two._children.length) {
            return false;
        }

        if (!attribMatch(one, two)) return false;

        for (var i = 0; i < one._children.length; i++) {
            if (!module.exports.equalNodes(one._children[i], two._children[i])) {
                return false;
            }
        }

        return true;
    }
318851
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $nspace, $current_nspace )
    {
        switch ( $functionName )
        {
            case $this->LName:
            {
                $textElements[] = $tpl->leftDelimiter();
            } break;
            case $this->RName:
            {
                $textElements[] = $tpl->rightDelimiter();
            } break;
        }
    }
994012
function getNth (elements, target) {
  var length = elements.length
  var count = 0
  for (var index = 0; index < length; index++) {
    var element = elements[index]
    if (!element.hasOwnProperty('deleted')) {
      if (count === target) {
        return index
      }
      count++
    }
  }
  return (index + 1)
}
757494
function(view, element) {
          var methods = {
            hasModifier: function(needle) {
              var tokens = ModifierUtil.split(element.attr('modifier'));
              needle = typeof needle === 'string' ? needle.trim() : '';

              return ModifierUtil.split(needle).some(function(needle) {
                return tokens.indexOf(needle) != -1;
              });
            },

            removeModifier: function(needle) {
              needle = typeof needle === 'string' ? needle.trim() : '';

              var modifier = ModifierUtil.split(element.attr('modifier')).filter(function(token) {
                return token !== needle;
              }).join(' ');

              element.attr('modifier', modifier);
            },

            addModifier: function(modifier) {
              element.attr('modifier', element.attr('modifier') + ' ' + modifier);
            },

            setModifier: function(modifier) {
              element.attr('modifier', modifier);
            },

            toggleModifier: function(modifier) {
              if (this.hasModifier(modifier)) {
                this.removeModifier(modifier);
              } else {
                this.addModifier(modifier);
              }
            }
          };

          for (var method in methods) {
            if (methods.hasOwnProperty(method)) {
              view[method] = methods[method];
            }
          }
        }
15479
function(syntax, name, minScore) {
			var result = this.fuzzyFindMatches(syntax, name, minScore)[0];
			if (result) {
				return result.value.parsedValue;
			}
		}
644219
function ($div, isInit, isForce, isOwn) {
            var data = $div.data('data');
            if (!data) return;

            var value = (data.tempValue !== undefined) ? data.tempValue : data.value;

            if (!isForce && data.oldValue !== undefined && data.oldValue == value && !data.ack) return;

            if (data.wType === 'number') {
                value = parseFloat((value || 0).toString().replace(',', '.'));
            }
            data.oldValue = value;

            if (data.temperature) {
                data.state = 'normal';
            } else if (value == data.min) {
                data.state = 'normal';
            } else if (value == data.max) {
                data.state = 'active';
            } else if (data.max &&
                (value === null    ||
                 value === ''      ||
                 value === undefined ||
                 value === 'false' ||
                 value === false))  {
                data.state = 'normal';
            } else {
                if (data.wType === 'number') {
                    if (data.max) {
                        if (value > data.min) {
                            data.state = 'active';
                        } else {
                            data.state = 'normal';
                        }
                    } else if (value) {
                        data.state = 'active';
                    } else {
                        data.state = 'normal';
                    }
                } else {
                    if (data.max) {
                        if (value == data.max) {
                            data.state = 'active';
                        } else {
                            data.state = 'normal';
                        }
                    } else if (value) {
                        data.state = 'active';
                    } else {
                        data.state = 'normal';
                    }
                }
            }

            if (vis.editMode && data.testActive) {
                data.state = (data.state === 'normal') ? 'active' : 'normal';
            }

            if (value !== null && value !== undefined) {
                $div.find('.vis-hq-nodata').remove();
            }

            switch (data.state) {
                case 'normal':
                    $('#' + data.wid + ' .vis-hq-main')
                        .removeClass(data.styleActive)
                        .addClass(data.styleNormal);

                    if (data.iconName || data.iconOn) {
                        var $img  = $div.find('.vis-hq-icon-img');

                        if ($img.attr('src') !== (data.iconName || '')) {
                            $img.attr('src', (data.iconName || ''));
                            vis.binds.hqwidgets.button.centerImage($div, data, $img);
                        }
                    }
                    if (data.captionOn) {
                        $div.find('.vis-hq-text-caption').html(data.caption || '');
                    }
                    break;
                case 'active':
                    $('#' + data.wid + ' .vis-hq-main')
                        .removeClass(data.styleNormal)
                        .addClass(data.styleActive);

                    if (data.iconName || data.iconOn) {
                        var $img  = $div.find('.vis-hq-icon-img');

                        if ($img.attr('src') !== (data.iconOn || data.iconName)) {
                            $img.attr('src', (data.iconOn || data.iconName));
                            vis.binds.hqwidgets.button.centerImage($div, data, $img);
                        }
                    }
                    if (data.captionOn) {
                        $div.find('.vis-hq-text-caption').html(data.captionOn);
                    }
                    break;
            }
            if (data.digits !== null && value !== null && value !== undefined) {
                if (typeof value !== 'number') value = parseFloat(value) || 0;
                value = value.toFixed(data.digits);
            }
            if (data.is_comma && value) value = value.toString().replace('.', ',');

            vis.binds.hqwidgets.button.showRightInfo($div, value);

            if ((!data.ack && !data['oid-working']) || (data['oid-working'] && data.working)) {
                $div.find('.vis-hq-working').show();
            } else {
                $div.find('.vis-hq-working').hide();
            }

            if (data['oid-battery']) $div.batteryIndicator('show', data.battery || false);

            if (data['oid-signal']) {
                $div.find('.vis-hq-signal').html(data.signal);
            }

            if (data['oid-humidity']) {
                var $h = $div.find('.vis-hq-humidity');
                if (!$h.length) {
                    vis.binds.hqwidgets.button.showCenterInfo($div, false, true);
                } else {
                    $h.html(Math.round(data.humidity || 0));
                }
            }

            if (data['oid-actual']) {
                var $a = $div.find('.vis-hq-actual');
                if (!$a.length) {
                    vis.binds.hqwidgets.button.showCenterInfo($div, false, true);
                } else {
                    if (typeof data.actual !== 'number') data.actual = parseFloat(data.actual) || 0;
                    $a.html((data.digits !== null) ? (data.actual || 0).toFixed(data.digits) : (data.actual || 0));
                }
            }

            if (data['oid-drive']) {
                $div.find('.vis-hq-drive').html(data.drive || 0);
            }

            // Show change effect
            if (data.changeEffect && ((!isInit && !isOwn) || (vis.editMode && data.testActive))) {
                var $main = $div.find('.vis-hq-main');
                $main.animateDiv(data.changeEffect, {color: data.waveColor});
            }
        }
182520
function (a, element, event, callback) {
                var cbCheck;
                for (var i = 0, l = a.length; i < l; i = i + 1) {
                    var li = a[i];
                    if (li && this.typesUtil.isObject(li[FN]) && !li[FN].$Callback) {
                        cbCheck = ("fn" in callback) && (li[FN].fn == callback.fn);
                    } else {
                        cbCheck = (li[FN] == callback);
                    }
                    if (li && cbCheck && li[EL] == element && li[TYPE] == event) {
                        return i;
                    }
                }

                return -1;
            }
613118
function(expr, options) {
                    var fn = options.fn;
                    options.fn = options.inverse;
                    options.inverse = fn;
                    return Mustache._helpers['if'].fn.apply(this, arguments);
                }
26644
function (el) {
        var opts = {}, ii, p,
            opts_arr = (el.attr('data-options') || ':').split(';'),
            opts_len = opts_arr.length;

        function isNumber (o) {
          return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
        }

        function trim(str) {
          if (typeof str === 'string') return $.trim(str);
          return str;
        }

        // parse options
        for (ii = opts_len - 1; ii >= 0; ii--) {
          p = opts_arr[ii].split(':');

          if (/true/i.test(p[1])) p[1] = true;
          if (/false/i.test(p[1])) p[1] = false;
          if (isNumber(p[1])) p[1] = parseInt(p[1], 10);

          if (p.length === 2 && p[0].length > 0) {
            opts[trim(p[0])] = trim(p[1]);
          }
        }

        return opts;
      }
1139753
function (Type, Arr, Obj, Node, Error, console) {
    var rawSet = function (dom, key, value) {
      /*
       * JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
       *
       * We fail on those invalid cases, only allowing numbers and booleans.
       */
      if (Type.isString(value) || Type.isBoolean(value) || Type.isNumber(value)) {
        dom.setAttribute(key, value + '');
      } else {
        console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
        throw new Error('Attribute value was not simple');
      }
    };

    var set = function (element, key, value) {
      rawSet(element.dom(), key, value);
    };

    var setAll = function (element, attrs) {
      var dom = element.dom();
      Obj.each(attrs, function (v, k) {
        rawSet(dom, k, v);
      });
    };

    var get = function (element, key) {
      var v = element.dom().getAttribute(key);

      // undefined is the more appropriate value for JS, and this matches JQuery
      return v === null ? undefined : v;
    };

    var has = function (element, key) {
      var dom = element.dom();

      // return false for non-element nodes, no point in throwing an error
      return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
    };

    var remove = function (element, key) {
      element.dom().removeAttribute(key);
    };

    var hasNone = function (element) {
      var attrs = element.dom().attributes;
      return attrs === undefined || attrs === null || attrs.length === 0;
    };

    var clone = function (element) {
      return Arr.foldl(element.dom().attributes, function (acc, attr) {
        acc[attr.name] = attr.value;
        return acc;
      }, {});
    };

    var transferOne = function (source, destination, attr) {
      // NOTE: We don't want to clobber any existing attributes
      if (has(source, attr) && !has(destination, attr)) set(destination, attr, get(source, attr));        
    };

    // Transfer attributes(attrs) from source to destination, unless they are already present
    var transfer = function (source, destination, attrs) {
      if (!Node.isElement(source) || !Node.isElement(destination)) return;
      Arr.each(attrs, function (attr) {
        transferOne(source, destination, attr);
      });
    };

    return {
      clone: clone,
      set: set,
      setAll: setAll,
      get: get,
      has: has,
      remove: remove,
      hasNone: hasNone,
      transfer: transfer
    };
  }
582060
function(val, ctx, partials, inverted) {
      if (isArray(val) && val.length === 0) {
        return false;
      }

      var func;
      if (typeof val == 'function') {
        val = this.ms(val, ctx, partials);
        if (typeof val == 'function') {
          func = val;
        }
      }

      var pass = !!val;

      if (!inverted && pass && ctx) {
        if (func) {
          ctx.push(func);
        } else {
          ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
        }
      }

      return pass;
    }
37198
function (elements, id) {
      return function (editor) {
        var i, textBlockElementsMap = editor.schema.getTextBlockElements();

        for (i = 0; i < elements.length; i++) {
          if (elements[i].nodeName === 'TABLE') {
            return null;
          }
        }

        for (i = 0; i < elements.length; i++) {
          if (elements[i].nodeName in textBlockElementsMap) {
            if (editor.dom.isEmpty(elements[i])) {
              return Matcher.result(id, Measure.getSelectionRect(editor));
            }

            return null;
          }
        }

        return null;
      };
    }