var __extends = this && this.__extends || function(d, b) {
  for(var p in b) {
    if(b.hasOwnProperty(p)) {
      d[p] = b[p]
    }
  }
  function __() {
    this.constructor = d
  }
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __)
};
var econda;
(function(econda) {
  var util;
  (function(util) {
    var DomHelper = function() {
      function DomHelper() {
      }
      DomHelper._useJQuery = function() {
        return this.useJQueryIfLoaded && typeof jQuery != "undefined"
      };
      DomHelper.update = function(element, html) {
        if(this._useJQuery()) {
          return jQuery(element).html(html)
        }else {
          return this._update(element, html)
        }
      };
      DomHelper.createFragmentFromHtml = function(html) {
        var frag = document.createDocumentFragment(), temp = document.createElement("div");
        temp.innerHTML = html;
        while(temp.firstChild) {
          frag.appendChild(temp.firstChild)
        }
        return frag
      };
      DomHelper.appendFromHtml = function(parentNode, html) {
        var temp = document.createElement("div");
        temp.innerHTML = html;
        while(temp.firstChild) {
          if(String(temp.firstChild.nodeName).toLowerCase() === "script") {
            var scriptText = temp.firstChild.textContent || temp.firstChild.innerHTML;
            var scriptNode = document.createElement("script");
            scriptNode.type = "text/javascript";
            try {
              scriptNode.appendChild(document.createTextNode(scriptText))
            }catch(e) {
              scriptNode.text = scriptText
            }
            parentNode.appendChild(scriptNode);
            temp.removeChild(temp.firstChild)
          }else {
            parentNode.appendChild(temp.firstChild)
          }
        }
      };
      DomHelper.empty = function(element) {
        var node = DomHelper.element(element);
        while(node.firstChild) {
          node.removeChild(node.firstChild)
        }
      };
      DomHelper._update = function(element, html) {
        var el = this.element(element);
        var ret = null;
        if(el) {
          el.innerHTML = html;
          this._handleJavascript(el);
          ret = el.innerHTML
        }
        return ret
      };
      DomHelper._handleJavascript = function(element) {
        var i, ii, scripts = element.getElementsByTagName("script");
        if(scripts.length > 0) {
          for(i = 0, ii = scripts.length;i < ii;i += 1) {
            var scriptNode = this._generateScriptNode(scripts[i].text || scripts[i].textContent || scripts[i].innerHTML || "");
            element.appendChild(scriptNode)
          }
        }
      };
      DomHelper._generateScriptNode = function(code) {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.appendChild(document.createTextNode(code));
        return script
      };
      DomHelper.isDocumentReady = function() {
        return document.readyState === "complete" || document.readyState === "interactive"
      };
      DomHelper.documentReady = function(callback) {
        if(DomHelper.isDocumentReady()) {
          callback();
          return
        }
        var called = false, isFrame = false;
        var doc = document, win = window;
        function ready() {
          if(called) {
            return
          }
          called = true;
          callback()
        }
        if(doc.addEventListener) {
          doc.addEventListener("DOMContentLoaded", ready, false)
        }else {
          if(doc.attachEvent) {
            try {
              isFrame = window.frameElement != null
            }catch(e) {
            }
            if(doc.documentElement && doc.documentElement.doScroll && !isFrame) {
              function tryScroll() {
                if(called) {
                  return
                }
                try {
                  doc.documentElement.doScroll("left");
                  ready()
                }catch(e) {
                  setTimeout(tryScroll, 10)
                }
              }
              tryScroll()
            }
            doc.attachEvent("onreadystatechange", function() {
              if(doc.readyState === "complete" || doc.readyState === "interactive") {
                ready()
              }
            })
          }
        }
        if(win.addEventListener) {
          win.addEventListener("load", ready, false)
        }else {
          if(win.attachEvent) {
            win.attachEvent("onload", ready)
          }else {
            var fn = win.onload;
            win.onload = function() {
              fn && fn(null);
              ready()
            }
          }
        }
      };
      DomHelper.remove = function(element) {
        var el = this.element(element);
        if(el) {
          el.parentNode.removeChild(el)
        }
      };
      DomHelper.elements = function(selector) {
        var el = null;
        if(this._useJQuery()) {
          return jQuery(selector)
        }
        if(typeof selector == "string") {
          if(selector.substr(0, 1) == "#") {
            el = document.getElementById(selector.substr(1))
          }else {
            el = document.getElementById(selector)
          }
        }else {
          el = selector
        }
        if(el) {
          return[el]
        }
        return{length:0}
      };
      DomHelper.element = function(element) {
        var el = this.elements(element);
        if(el.length > 0) {
          return el[0]
        }else {
          return null
        }
      };
      DomHelper.useJQueryIfLoaded = true;
      return DomHelper
    }();
    util.DomHelper = DomHelper
  })(util = econda.util || (econda.util = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var util;
  (function(util) {
    var LogItem = function() {
      function LogItem(timestamp, type, message, data) {
        this.timestamp = null;
        this.type = "info";
        this.message = null;
        this.data = null;
        this.timestamp = timestamp;
        this.type = type;
        this.message = message;
        this.data = data
      }
      LogItem.TYPE_INFO = "info";
      LogItem.TYPE_WARNING = "warning";
      LogItem.TYPE_ERROR = "error";
      return LogItem
    }();
    var LogViewer = function() {
      function LogViewer() {
        this.container = null;
        this.autoScroll = true;
        this.queue = [];
        this.timeout = null
      }
      LogViewer.prototype.log = function(message, data) {
        var item = new LogItem(new Date, LogItem.TYPE_INFO, message, data);
        this.queue.push(item);
        this.writeQueue()
      };
      LogViewer.prototype.warn = function(message, data) {
        var item = new LogItem(new Date, LogItem.TYPE_WARNING, message, data);
        this.queue.push(item);
        this.writeQueue()
      };
      LogViewer.prototype.error = function(message, data) {
        var item = new LogItem(new Date, LogItem.TYPE_ERROR, message, data);
        this.queue.push(item);
        this.writeQueue()
      };
      LogViewer.prototype.writeQueue = function() {
        var container = econda.util.DomHelper.element(this.container);
        if(container != null) {
          var item = null;
          while(item = this.queue.shift()) {
            this.writeItemToContainer(item, container)
          }
        }else {
          if(this.timeout == null) {
            var cmp = this;
            setTimeout(function() {
              cmp.writeQueue()
            }, 250)
          }
        }
      };
      LogViewer.prototype.writeItemToContainer = function(item, container) {
        var minutes = item.timestamp.getMinutes();
        var mStr = minutes < 10 ? "0" + minutes.toString() : minutes.toString();
        var html = [item.timestamp.getHours().toString(), ":", mStr, ".", item.timestamp.getSeconds().toString(), " - ", item.message];
        var domItem = document.createElement("p");
        domItem.innerHTML = html.join("");
        domItem.style.margin = "0";
        domItem.style.padding = "2px";
        domItem.style.fontFamily = "Fixed, monospace";
        domItem.style.fontSize = "12px";
        switch(item.type) {
          case LogItem.TYPE_ERROR:
            domItem.style.backgroundColor = "#FF9999";
            break;
          case LogItem.TYPE_WARNING:
            domItem.style.backgroundColor = "#FFFF99";
            break
        }
        container.appendChild(domItem);
        if(this.autoScroll) {
          container.scrollTop = container.scrollHeight
        }
      };
      LogViewer.prototype.getContainerElement = function() {
        var container = null;
        if(this.container instanceof HTMLElement) {
          container = this.container
        }else {
          container = document.getElementById(this.container)
        }
        return container
      };
      return LogViewer
    }();
    util.LogViewer = LogViewer
  })(util = econda.util || (econda.util = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var net;
  (function(net) {
    var Uri = function() {
      function Uri(uri) {
        this.uri = null;
        this.scheme = null;
        this.host = null;
        this.path = null;
        this.query = null;
        this.hash = null;
        if(uri instanceof Uri) {
          return uri
        }else {
          this.uri = uri;
          if(this.uri) {
            this.parseUri()
          }
        }
      }
      Uri.prototype.getScheme = function() {
        if(this.scheme) {
          return this.scheme.toLowerCase()
        }else {
          return null
        }
      };
      Uri.prototype.setScheme = function(scheme) {
        var scheme = (new String(scheme)).toLocaleLowerCase();
        if(this.uri !== null) {
          this.uri = this.uri.replace(/^\w*\:/, scheme + ":")
        }
        this.resetComponents();
        this.parseUri()
      };
      Uri.prototype.getHost = function() {
        return this.host
      };
      Uri.prototype.getPath = function() {
        return this.path
      };
      Uri.prototype.getFilename = function() {
        var path = this.path;
        if(typeof path == "string" && path.lastIndexOf("/") > -1) {
          return path.substr(path.lastIndexOf("/") + 1)
        }else {
          return null
        }
      };
      Uri.prototype.getQuery = function() {
        return this.query
      };
      Uri.prototype.getHash = function() {
        return this.hash
      };
      Uri.prototype.parseUri = function() {
        var uri = this.uri;
        var regex = /^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/;
        var matches = uri.match(regex);
        this.scheme = matches[1] || null;
        this.host = matches[2] || null;
        this.path = matches[3] || null;
        this.query = matches[4] || null;
        this.hash = matches[5] || null;
        return this
      };
      Uri.prototype.resetComponents = function() {
        this.scheme = null;
        this.host = null;
        this.path = null;
        this.query = null;
        this.hash = null;
        return this
      };
      Uri.prototype.getParam = function(name) {
        var parts = [];
        if(typeof this.query === "string") {
          parts = this.query.split("&")
        }
        var params = {};
        for(var n = 0;n < parts.length;n++) {
          var itemParts = String(parts[n]).split("=");
          params[itemParts[0]] = itemParts.length >= 2 ? itemParts[1] : ""
        }
        return params[name] || null
      };
      Uri.prototype.appendParams = function(params) {
        var uri = this.uri;
        var hashpos = uri.lastIndexOf("#"), baseUri = hashpos > -1 ? uri.substring(0, hashpos) : uri, hash = hashpos > -1 ? uri.substr(hashpos) : "", hasParams = uri.indexOf("?") > -1, ret;
        ret = baseUri + (hasParams ? "&" : "?") + Uri.concatParams(params) + hash;
        this.uri = ret;
        this.resetComponents();
        this.parseUri();
        return this
      };
      Uri.prototype.match = function(pattern) {
        return this.uri.match(pattern)
      };
      Uri.prototype.clone = function() {
        var clone = new Uri(this.uri);
        return clone
      };
      Uri.concatParams = function(params) {
        var parts = [];
        for(var name in params) {
          parts.push(name + "=" + encodeURIComponent(params[name]))
        }
        return parts.join("&")
      };
      Uri.prototype.toString = function() {
        return this.uri
      };
      Uri.SCHEME_HTTP = "http";
      Uri.SCHEME_HTTPS = "https";
      Uri.SCHEME_FTP = "ftp";
      return Uri
    }();
    net.Uri = Uri
  })(net = econda.net || (econda.net = {}))
})(econda || (econda = {}));
if(typeof window["econdaConfig"] == "undefined") {
  window["econdaConfig"] = {}
}
var econda;
(function(econda) {
  var debug = function() {
    function debug() {
    }
    debug.setEnabled = function(enabled) {
      econdaConfig.debug = enabled;
      return this
    };
    debug.getEnabled = function() {
      return econdaConfig.debug
    };
    debug.setExceptionsOnError = function(enabled) {
      econdaConfig.exceptionsOnError = enabled;
      return this
    };
    debug.getExceptionsOnError = function() {
      return econdaConfig.exceptionsOnError || false
    };
    debug.setOutputContainer = function(htmlElement) {
      econdaConfig.debugOutputContainer = htmlElement;
      this.logViewerInstance = null;
      return this
    };
    debug.error = function() {
      var args = [];
      for(var _i = 0;_i < arguments.length;_i++) {
        args[_i - 0] = arguments[_i]
      }
      if(econdaConfig.debug != true) {
        return this
      }
      var data = [];
      for(var n = 1;n < arguments.length;n++) {
        data.push(arguments[n])
      }
      if(typeof console != "undefined" && console.error) {
        console.error("[ec] " + arguments[0], data)
      }
      if(econdaConfig.debugOutputContainer != null) {
        this.setupLogViewer();
        this.logViewerInstance.error(arguments[0], data)
      }
      if(econdaConfig.exceptionsOnError) {
        throw new Error(arguments[0]);
      }
      return this
    };
    debug.warn = function() {
      var args = [];
      for(var _i = 0;_i < arguments.length;_i++) {
        args[_i - 0] = arguments[_i]
      }
      if(econdaConfig.debug != true) {
        return this
      }
      var data = [];
      for(var n = 1;n < arguments.length;n++) {
        data.push(arguments[n])
      }
      if(typeof console != "undefined" && console.warn) {
        console.warn("[ec] " + arguments[0], data)
      }
      if(econdaConfig.debugOutputContainer != null) {
        this.setupLogViewer();
        this.logViewerInstance.warn(arguments[0], data)
      }
      return this
    };
    debug.log = function() {
      var args = [];
      for(var _i = 0;_i < arguments.length;_i++) {
        args[_i - 0] = arguments[_i]
      }
      if(econdaConfig.debug != true) {
        return this
      }
      var data = [];
      for(var n = 1;n < arguments.length;n++) {
        data.push(arguments[n])
      }
      if(typeof console != "undefined" && console.log) {
        data.length > 0 ? console.log("[ec] " + arguments[0], data) : console.log("[ec] " + arguments[0])
      }
      if(econdaConfig.debugOutputContainer != null) {
        this.setupLogViewer();
        this.logViewerInstance.log(arguments[0], data)
      }
      return this
    };
    debug.setupLogViewer = function() {
      if(this.logViewerInstance == null) {
        this.logViewerInstance = new econda.util.LogViewer;
        this.logViewerInstance.container = econdaConfig.debugOutputContainer
      }
    };
    debug.logViewerInstance = null;
    return debug
  }();
  econda.debug = debug
})(econda || (econda = {}));
var econda;
(function(econda) {
  var util;
  (function(util) {
    var ArrayUtils = function() {
      function ArrayUtils() {
      }
      ArrayUtils.indexOf = function(arr, needle) {
        if(Array.prototype.indexOf) {
          return arr.indexOf(needle)
        }else {
          for(var n = 0;n < arr.length;n++) {
            if(arr[n] == needle) {
              return n
            }
          }
          return-1
        }
      };
      ArrayUtils.contains = function(arr, needle) {
        return ArrayUtils.indexOf(arr, needle) > -1
      };
      ArrayUtils.isArray = function(obj) {
        if(!this.isArrayFn) {
          this.isArrayFn = typeof Array.isArray != "undefined" ? Array.isArray : function(obj) {
            return Object.prototype.toString.call(obj) === "[object Array]"
          }
        }
        return this.isArrayFn(obj)
      };
      ArrayUtils.shuffle = function(arr) {
        var m = arr.length, t, i;
        while(m) {
          i = Math.floor(Math.random() * m--);
          t = arr[m];
          arr[m] = arr[i];
          arr[i] = t
        }
        return arr
      };
      ArrayUtils.remove = function(arr, itemOrItemsToRemove) {
        if(typeof itemOrItemsToRemove === "function") {
          return this._removeByFunction(arr, itemOrItemsToRemove)
        }
        var itemsToRemove = ArrayUtils.isArray(itemOrItemsToRemove) ? itemOrItemsToRemove : [itemOrItemsToRemove];
        return this._removeItems(arr, itemsToRemove)
      };
      ArrayUtils._removeItems = function(arr, itemsToRemove) {
        var itemsRemoved = [];
        for(var i = 0;i < itemsToRemove.length;i++) {
          var index = arr.indexOf(itemsToRemove[i]);
          if(index > -1) {
            itemsRemoved = itemsRemoved.concat(arr.splice(index, 1))
          }
        }
        return itemsRemoved
      };
      ArrayUtils._removeByFunction = function(arr, filterFunction) {
        var itemsRemoved = [];
        for(var n = 0;n < arr.length;n++) {
          if(filterFunction(arr[n], n, arr) === true) {
            itemsRemoved = itemsRemoved.concat(arr.splice(n, 1));
            n--
          }
        }
        return itemsRemoved
      };
      ArrayUtils.filter = function(arr, filterFunction) {
        if(typeof filterFunction !== "function") {
          return arr
        }
        if(typeof arr.filter === "function") {
          return arr.filter(filterFunction)
        }
        var ret = [];
        for(var n = 0;n < arr.length;n++) {
          if(filterFunction(arr[n], n, arr) === true) {
            ret.push(arr[n])
          }
        }
        return ret
      };
      ArrayUtils.isArrayFn = null;
      return ArrayUtils
    }();
    util.ArrayUtils = ArrayUtils
  })(util = econda.util || (econda.util = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var base;
  (function(base) {
    var BaseClass = function() {
      function BaseClass() {
        this.__defaultProperty = null
      }
      BaseClass.prototype.initConfig = function(cfg, defaultPropertyName) {
        if(defaultPropertyName === void 0) {
          defaultPropertyName = null
        }
        if(defaultPropertyName != null) {
          this.__defaultProperty = defaultPropertyName
        }
        if(typeof cfg != "undefined") {
          this.set(cfg)
        }
      };
      BaseClass.prototype.set = function(cfg, newValue) {
        var cmp = this;
        var propertyName, functionName;
        if(typeof cfg == "object") {
          for(propertyName in cfg) {
            functionName = cmp.getSetterName(propertyName);
            if(typeof this[functionName] != "undefined") {
              this[functionName](cfg[propertyName])
            }else {
              econda.debug.error("Cannot set " + propertyName + " in " + this._getClassName() + ": no setter defined.")
            }
          }
        }else {
          if(typeof cfg == "string" && arguments.length == 2) {
            propertyName = cfg;
            functionName = cmp.getSetterName(propertyName);
            if(typeof this[functionName] != "undefined") {
              this[functionName](newValue)
            }else {
              econda.debug.error("Cannot set " + propertyName + " in " + this._getClassName() + ": no setter defined.")
            }
          }else {
            if(typeof cfg != "undefined" && cmp.__defaultProperty) {
              functionName = cmp.getSetterName(cmp.__defaultProperty);
              cmp[functionName](cfg)
            }
          }
        }
        return this
      };
      BaseClass.prototype.get = function(propertyName) {
        var functionName = this.getGetterName(propertyName);
        if(typeof this[functionName] != "undefined") {
          return this[functionName]()
        }
        econda.debug.error("Cannot get " + propertyName + " in " + this._getClassName() + ": no getter defined.")
      };
      BaseClass.prototype._getClassName = function() {
        try {
          return this.constructor.name
        }catch(e) {
          return null
        }
      };
      BaseClass.prototype.getSetterName = function(propertyName) {
        return"set" + propertyName.substr(0, 1).toUpperCase() + propertyName.substr(1)
      };
      BaseClass.prototype.getGetterName = function(propertyName) {
        return"get" + propertyName.substr(0, 1).toUpperCase() + propertyName.substr(1)
      };
      BaseClass.prototype.setArray = function(fieldName, data, type, options) {
        if(type === void 0) {
          type = null
        }
        this[fieldName] = [];
        this.addArray(fieldName, data, type, options);
        return this
      };
      BaseClass.prototype.addArray = function(fieldName, data, type, options) {
        if(type === void 0) {
          type = null
        }
        if(typeof options === "undefined" || options === null) {
          options = {}
        }
        var collection = data;
        if(econda.util.ArrayUtils.isArray(data) == false) {
          collection = [data]
        }
        for(var n = 0;n < collection.length;n++) {
          var input;
          var item;
          if(typeof options.itemFilter === "function") {
            input = options.itemFilter.call(this, collection[n])
          }else {
            input = collection[n]
          }
          if(type === null || input instanceof type) {
            item = input
          }else {
            item = new type(input)
          }
          if(typeof options.callback === "function") {
            options.callback.call(this, item)
          }
          this[fieldName].push(item)
        }
        return this
      };
      BaseClass.prototype.clone = function() {
        var ret = new this.constructor;
        for(var key in this) {
          ret[key] = this[key]
        }
        return ret
      };
      return BaseClass
    }();
    base.BaseClass = BaseClass
  })(base = econda.base || (econda.base = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var Category = function(_super) {
      __extends(Category, _super);
      function Category(cfg) {
        _super.call(this);
        this.path = null;
        this.getPath = function() {
          return this.path
        };
        this.__defaultProperty = "path";
        if(cfg instanceof Category) {
          return cfg
        }
        this.initConfig(cfg)
      }
      Category.prototype.setPath = function(path) {
        if(typeof path !== "string") {
          econda.debug.error("Category expects a String as path. Got: " + path, path)
        }else {
          if(path.substr(0, 1) == "/") {
            this.path = path.substring(1)
          }else {
            this.path = path
          }
        }
        return this
      };
      Category.prototype.toString = function() {
        return this.getPath()
      };
      return Category
    }(econda.base.BaseClass);
    media.Category = Category
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var Content = function(_super) {
      __extends(Content, _super);
      function Content(cfg) {
        _super.call(this);
        this.name = null;
        this.category = null;
        this.__defaultProperty = "name";
        if(cfg instanceof Content) {
          return cfg
        }
        this.initConfig(cfg)
      }
      Content.prototype.getName = function() {
        return this.name
      };
      Content.prototype.setName = function(name) {
        this.name = name;
        return this
      };
      Content.prototype.getCategory = function() {
        return this.category
      };
      Content.prototype.setCategory = function(category) {
        this.category = new media.Category(category);
        return this
      };
      Content.prototype.toString = function() {
        var cat = this.getCategory();
        var ret = "";
        if(cat != null) {
          ret = cat.toString() + "/" + this.getName()
        }else {
          ret = this.getName()
        }
        return ret
      };
      return Content
    }(econda.base.BaseClass);
    media.Content = Content
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var transport;
    (function(transport) {
      var Uri = econda.net.Uri;
      var MediaEvent = function(_super) {
        __extends(MediaEvent, _super);
        function MediaEvent(cfg) {
          _super.call(this);
          this.eventName = null;
          this.contentLabel = null;
          this.mediaType = "video";
          this.position = 0;
          this.duration = 0;
          this.trackerId = 0;
          this.previewUri = null;
          if(cfg instanceof MediaEvent) {
            return cfg
          }
          this.initConfig(cfg)
        }
        MediaEvent.prototype.getEventName = function() {
          return this.eventName
        };
        MediaEvent.prototype.setEventName = function(eventName) {
          this.eventName = eventName;
          return this
        };
        MediaEvent.prototype.getContentLabel = function() {
          return this.contentLabel
        };
        MediaEvent.prototype.setContentLabel = function(contentLabel) {
          this.contentLabel = contentLabel;
          return this
        };
        MediaEvent.prototype.getMediaType = function() {
          return this.mediaType
        };
        MediaEvent.prototype.setMediaType = function(type) {
          this.mediaType = type;
          return this
        };
        MediaEvent.prototype.getPosition = function() {
          return this.position
        };
        MediaEvent.prototype.setPosition = function(currentPosition) {
          this.position = currentPosition;
          return this
        };
        MediaEvent.prototype.getDuration = function() {
          return this.duration
        };
        MediaEvent.prototype.setDuration = function(duration) {
          this.duration = duration;
          return this
        };
        MediaEvent.prototype.getTrackerId = function() {
          return this.trackerId
        };
        MediaEvent.prototype.setTrackerId = function(id) {
          this.trackerId = id;
          return this
        };
        MediaEvent.prototype.getPreviewUri = function() {
          return this.previewUri
        };
        MediaEvent.prototype.setPreviewUri = function(uri) {
          this.previewUri = new Uri(uri)
        };
        return MediaEvent
      }(econda.base.BaseClass);
      transport.MediaEvent = MediaEvent
    })(transport = media.transport || (media.transport = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var transport;
    (function(transport) {
      var MediaEvent = econda.media.transport.MediaEvent;
      var Direct = function(_super) {
        __extends(Direct, _super);
        function Direct(cfg) {
          _super.call(this);
          this.keepalive = Direct.INTERVAL_AUTO;
          this.getKeepalive = function() {
            return this.keepalive
          };
          this.disabled = false;
          this._lastRequest = null;
          this.keepaliveHandler = {};
          if(cfg instanceof Direct) {
            return cfg
          }
          this.initConfig(cfg)
        }
        Direct.prototype.setType = function(type) {
          if(type.toLowerCase() != "direct") {
            econda.debug.error("econda.media.transport.Direct accepts only type=direct")
          }
          return this
        };
        Direct.prototype.setKeepalive = function(seconds) {
          if(typeof seconds != "number" && seconds != "auto") {
            econda.debug.error("Got invalid value for MediaTracker.keepalive: " + seconds)
          }else {
            this.keepalive = seconds
          }
          return this
        };
        Direct.prototype.disable = function() {
          this.disabled = true;
          return this
        };
        Direct.prototype.enable = function() {
          this.disabled = false;
          return this
        };
        Direct.prototype.setDisabled = function(isDisabled) {
          this.disabled = isDisabled == true;
          return this
        };
        Direct.prototype.isDisabled = function() {
          return this.disabled
        };
        Direct.prototype.sendMediaEvent = function(mediaEvent) {
          if(!(mediaEvent instanceof MediaEvent)) {
            econda.debug.error("Proxy.sendMediaEvent expects object of type econda.media.transport.MediaEvent as parameter")
          }
          var srvEventName, eventName = mediaEvent.getEventName();
          switch(mediaEvent.getEventName()) {
            case "keepalive":
              srvEventName = "keepalive";
              break;
            case "play":
              srvEventName = "play";
              break;
            case "pause":
              srvEventName = "pause";
              break;
            case "stop":
              srvEventName = "ended";
              break;
            default:
              return this
          }
          var data = [mediaEvent.getContentLabel(), srvEventName, mediaEvent.getMediaType(), mediaEvent.getPosition(), mediaEvent.getDuration(), Math.round((new Date).getTime() - econda.media.transport.Proxy.__pageInitDate.getTime()), mediaEvent.getTrackerId(), mediaEvent.getPreviewUri() ? mediaEvent.getPreviewUri().toString() : null];
          econda.debug.log("Sending media event: " + eventName, data);
          var dataToSend = {type:"event", media:data};
          if(!this.isDisabled()) {
            if(typeof emosPropertiesEvent == "undefined") {
              econda.debug.error("Could not sent media event: Function emosPropertiesEvent() is undefined")
            }else {
              emosPropertiesEvent(dataToSend)
            }
          }else {
            econda.debug.log("Request not sent, tracking is disabled in proxy.")
          }
          this._lastRequest = dataToSend;
          if(eventName == "play") {
            this.startKeepalive(mediaEvent)
          }
          if(eventName == "pause" || eventName == "stop") {
            this.stopKeepalive(mediaEvent)
          }
          return this
        };
        Direct.prototype.startKeepalive = function(mediaEvent) {
          var cmp = this;
          var keepaliveInterval, trackerId = mediaEvent.getTrackerId(), keepaliveEvent;
          if(this.keepalive != "0") {
            keepaliveEvent = mediaEvent.clone();
            keepaliveEvent.setEventName("keepalive");
            keepaliveInterval = this.keepalive == Direct.INTERVAL_AUTO ? 1E4 : Number(this.keepalive);
            this.keepaliveHandler[trackerId] = setInterval(function() {
              keepaliveEvent.setPosition(keepaliveEvent.getPosition() + keepaliveInterval / 1E3);
              cmp.sendMediaEvent(keepaliveEvent)
            }, keepaliveInterval)
          }
          return this
        };
        Direct.prototype.stopKeepalive = function(mediaEvent) {
          var trackerId = mediaEvent.getTrackerId();
          if(typeof this.keepaliveHandler[trackerId] != "undefined") {
            clearInterval(this.keepaliveHandler[trackerId])
          }
          return this
        };
        Direct.INTERVAL_AUTO = "auto";
        return Direct
      }(econda.base.BaseClass);
      transport.Direct = Direct
    })(transport = media.transport || (media.transport = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var transport;
    (function(transport) {
      var Direct = econda.media.transport.Direct;
      var Proxy = function() {
        function Proxy() {
        }
        Proxy.getInstance = function() {
          if(Proxy.__instance == null) {
            Proxy.createDefaultInstance()
          }
          return Proxy.__instance
        };
        Proxy.configure = function(cfg) {
          if(typeof cfg.type != "string") {
            econda.debug.error("Error in proxy.configure: You must set a proxy type.");
            return
          }
          var type = cfg.type.toLowerCase();
          var proxy = null;
          switch(type) {
            case "direct":
              proxy = new Direct(cfg);
              break;
            default:
              econda.debug.error("To proxy found for type: " + type)
          }
          Proxy.__instance = proxy
        };
        Proxy.createDefaultInstance = function() {
          Proxy.configure({type:"direct"})
        };
        Proxy.__pageInitDate = new Date;
        Proxy.__instance = null;
        return Proxy
      }();
      transport.Proxy = Proxy
    })(transport = media.transport || (media.transport = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var Uri = econda.net.Uri;
    var ArrayUtils = econda.util.ArrayUtils;
    var MediaEvent = econda.media.transport.MediaEvent;
    var MediaTracker = function(_super) {
      __extends(MediaTracker, _super);
      function MediaTracker(cfg) {
        _super.call(this);
        this.__instanceId = 0;
        this._initialized = false;
        this.content = null;
        this.type = "video";
        this.duration = null;
        this.previewUri = null;
        this.position = 0;
        this.state = MediaTracker.STATE_UNINITIALIZED;
        this._queuedEvents = [];
        if(cfg instanceof MediaTracker) {
          return cfg
        }
        this.__instanceId = MediaTracker.__instanceCount++;
        this.initConfig(cfg)
      }
      MediaTracker.prototype.getContent = function() {
        return this.content
      };
      MediaTracker.prototype.setContent = function(content) {
        if(this.state == MediaTracker.STATE_PLAYING || this.state == MediaTracker.STATE_PAUSED) {
          econda.debug.error("Trying to modify content information on an already playing tracker.")
        }else {
          this.content = new econda.media.Content(content)
        }
        return this
      };
      MediaTracker.prototype.getType = function() {
        return this.type
      };
      MediaTracker.prototype.setType = function(type) {
        if(typeof type != "string") {
          econda.debug.error("MediaTracker.setType expects as String. Got: " + type, type)
        }else {
          type = type.toLowerCase();
          if(ArrayUtils.contains([MediaTracker.TYPE_AUDIO, MediaTracker.TYPE_VIDEO], type) === false) {
            econda.debug.error("MediaTracker.setType expects 'audio' or 'video' as parameter. Got: " + type, type)
          }else {
            this.type = type
          }
        }
        return this
      };
      MediaTracker.prototype.getDuration = function() {
        return this.duration
      };
      MediaTracker.prototype.setDuration = function(seconds) {
        this.duration = Number(seconds);
        return this
      };
      MediaTracker.prototype.getPreviewUri = function() {
        return this.previewUri
      };
      MediaTracker.prototype.setPreviewUri = function(uri) {
        var uriObj = new Uri(uri);
        if(uriObj.getScheme() !== Uri.SCHEME_HTTPS) {
          econda.debug.error("preview uri MUST be a valid SSL uri!")
        }else {
          this.previewUri = uriObj
        }
        return this
      };
      MediaTracker.prototype.getPosition = function() {
        return this.position
      };
      MediaTracker.prototype.setPosition = function(seconds) {
        this.position = Number(seconds);
        return this
      };
      MediaTracker.prototype.getState = function() {
        return this.state
      };
      MediaTracker.prototype.getProxy = function() {
        return econda.media.transport.Proxy.getInstance()
      };
      MediaTracker.prototype.init = function() {
        var ok = true;
        ok = ok && this.content instanceof econda.media.Content && "" != this.content.getName();
        ok = ok && (this.type == MediaTracker.TYPE_AUDIO || this.type == MediaTracker.TYPE_VIDEO);
        ok = ok && this.duration != null;
        if(ok) {
          econda.debug.log("MediaTracker initialized.", this);
          this.state = MediaTracker.STATE_INITIALIZED;
          this._initialized = true;
          this.sendQueuedEvents()
        }else {
          econda.debug.error("Could not initialize MediaTracker.", this)
        }
        return this
      };
      MediaTracker.prototype.setState = function(state, position) {
        var oldState;
        if(typeof state != "string") {
          econda.debug.error("State value must be a string.")
        }else {
          oldState = this.state;
          state = state.toLowerCase();
          if(ArrayUtils.contains(["playing", "paused", "stopped"], state) == false) {
            econda.debug.error("Invalid state value given: " + state)
          }else {
            if(this.state == MediaTracker.STATE_UNINITIALIZED && state != MediaTracker.STATE_INITIALIZED) {
              econda.debug.warn("Got playing/paused/stopped state changed but MediaTracker is uninitialized. Please initialize tracker first.", this)
            }
            this.state = state;
            if(typeof position != "undefined") {
              this.position = Number(position)
            }
            if(oldState != state) {
              var eventNames = {playing:"play", paused:"pause", stopped:"stop"};
              if(this._initialized) {
                this.sendMediaEvent(eventNames[state])
              }else {
                this.queueMediaEvent(eventNames[state])
              }
            }
          }
        }
        return this
      };
      MediaTracker.prototype.queueMediaEvent = function(eventName) {
        this._queuedEvents.push(eventName)
      };
      MediaTracker.prototype.sendQueuedEvents = function() {
        for(var n = 0;n < this._queuedEvents.length;n++) {
          this.sendMediaEvent(this._queuedEvents[n])
        }
        this._queuedEvents = []
      };
      MediaTracker.prototype.sendMediaEvent = function(eventName) {
        var cmp = this, event = new MediaEvent({contentLabel:cmp.getContent().toString(), eventName:eventName, mediaType:cmp.getType(), position:Math.round(cmp.getPosition()), duration:Math.round(cmp.getDuration()), previewUri:cmp.getPreviewUri(), trackerId:cmp.__instanceId});
        if(typeof this.onBeforeTrackingRequest === "function") {
          this.onBeforeTrackingRequest(event)
        }
        this.getProxy().sendMediaEvent(event)
      };
      MediaTracker.TYPE_VIDEO = "video";
      MediaTracker.TYPE_AUDIO = "audio";
      MediaTracker.STATE_INITIALIZED = "initialized";
      MediaTracker.STATE_UNINITIALIZED = "uninitialized";
      MediaTracker.STATE_PLAYING = "playing";
      MediaTracker.STATE_PAUSED = "paused";
      MediaTracker.STATE_STOPPED = "stopped";
      MediaTracker.__instanceCount = 0;
      return MediaTracker
    }(econda.base.BaseClass);
    media.MediaTracker = MediaTracker
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var helper;
    (function(helper) {
      var DomHelper = econda.util.DomHelper;
      var MediaTracker = econda.media.MediaTracker;
      var HtmlAudioTracker = function(_super) {
        __extends(HtmlAudioTracker, _super);
        function HtmlAudioTracker(cfg) {
          _super.call(this);
          this.tracker = null;
          this.player = null;
          this.__defaultProperty = "player";
          this.ve = null;
          this.playerDataLoaded = false;
          this.trackerData = {};
          this.cuedSeekedEvent = null;
          if(cfg instanceof HtmlAudioTracker) {
            return cfg
          }
          this.initConfig(cfg)
        }
        HtmlAudioTracker.prototype.getTracker = function() {
          return this.tracker
        };
        HtmlAudioTracker.prototype.setTracker = function(tracker) {
          this.tracker = new MediaTracker(tracker);
          this.updateTrackerData();
          return this
        };
        HtmlAudioTracker.prototype.getPlayer = function() {
          return this.player
        };
        HtmlAudioTracker.prototype.setPlayer = function(domNodeOrId) {
          var domNode;
          if(!domNodeOrId) {
            econda.debug.error("No dom node given in HtmlAudioTracker.setPlayer().");
            return this
          }
          domNode = DomHelper.element(domNodeOrId);
          if(!domNode) {
            econda.debug.error("No dom node found with given element id: " + domNodeOrId);
            return this
          }
          if(typeof domNode.tagName == "undefined" || domNode.tagName.toLowerCase() != "audio") {
            econda.debug.error("Given element is not an html audio tag in HtmlAudioTracker.setPlayer().", domNode);
            return this
          }
          this.player = domNode;
          this.ve = domNode;
          this.addEventListeners();
          return this
        };
        HtmlAudioTracker.prototype.updateTrackerData = function(property, value) {
          if(typeof property != "undefined") {
            this.trackerData[property] = value
          }
          if(this.tracker !== null) {
            this.tracker.set(this.trackerData)
          }
          return this
        };
        HtmlAudioTracker.prototype.addEventListeners = function() {
          var cmp = this;
          var e = this.player;
          e.addEventListener("loadeddata", function() {
            cmp.handleLoadedDataEvent.apply(cmp, arguments)
          });
          e.addEventListener("seeking", function() {
            cmp.handleSeekingEvent.apply(cmp, arguments)
          });
          e.addEventListener("seeked", function() {
            cmp.handleSeekedEvent.apply(cmp, arguments)
          });
          e.addEventListener("play", function() {
            cmp.handlePlayEvent.apply(cmp, arguments)
          });
          e.addEventListener("pause", function() {
            cmp.handlePauseEvent.apply(cmp, arguments)
          });
          e.addEventListener("ended", function() {
            cmp.handleEndedEvent.apply(cmp, arguments)
          });
          return this
        };
        HtmlAudioTracker.prototype.handleLoadedDataEvent = function(event) {
          econda.debug.log("got loadeddata event");
          this.updateTrackerData("duration", this.ve.duration);
          this.playerDataLoaded = true;
          if(this.tracker) {
            this.tracker.init()
          }
        };
        HtmlAudioTracker.prototype.handleSeekingEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got seeking event");
          if(this.cuedSeekedEvent !== null) {
            clearTimeout(this.cuedSeekedEvent);
            this.cuedSeekedEvent = null
          }
          if(t) {
            t.setState("paused", this.ve.currentTime)
          }
        };
        HtmlAudioTracker.prototype.handleSeekedEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got seeked event");
          if(t) {
            var pos = this.ve.currentTime;
            this.cuedSeekedEvent = setTimeout(function() {
              t.setState("playing", pos)
            }, 250)
          }
        };
        HtmlAudioTracker.prototype.handlePlayEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got play event");
          if(t) {
            t.setState("playing", this.ve.currentTime)
          }
        };
        HtmlAudioTracker.prototype.handlePauseEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got pause event");
          if(t) {
            t.setState("paused", this.ve.currentTime)
          }
        };
        HtmlAudioTracker.prototype.handleEndedEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got ended event");
          if(t) {
            t.setState("stopped", this.ve.currentTime)
          }
        };
        return HtmlAudioTracker
      }(econda.base.BaseClass);
      helper.HtmlAudioTracker = HtmlAudioTracker
    })(helper = media.helper || (media.helper = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var util;
  (function(util) {
    var ObjectUtils = function() {
      function ObjectUtils() {
      }
      ObjectUtils.forEachOwnProperty = function(obj, callback) {
        if(typeof obj === "object" && obj !== null) {
          for(var key in obj) {
            if(obj.hasOwnProperty(key)) {
              callback(obj[key], key)
            }
          }
        }
      };
      return ObjectUtils
    }();
    util.ObjectUtils = ObjectUtils
  })(util = econda.util || (econda.util = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var helper;
    (function(helper) {
      var DomHelper = econda.util.DomHelper;
      var ObjectUtils = econda.util.ObjectUtils;
      var HtmlVideoTracker = function(_super) {
        __extends(HtmlVideoTracker, _super);
        function HtmlVideoTracker(cfg) {
          _super.call(this);
          this.tracker = null;
          this.player = null;
          this.__defaultProperty = "player";
          this.playerDataLoaded = false;
          this.trackerData = {};
          this.cuedSeekedEvent = null;
          if(cfg instanceof HtmlVideoTracker) {
            return cfg
          }
          this.initConfig(cfg)
        }
        HtmlVideoTracker.prototype.getTracker = function() {
          return this.tracker
        };
        HtmlVideoTracker.prototype.setTracker = function(tracker) {
          this.tracker = new econda.media.MediaTracker(tracker);
          this.updateTrackerData();
          return this
        };
        HtmlVideoTracker.prototype.getPlayer = function() {
          return this.player
        };
        HtmlVideoTracker.prototype.setPlayer = function(domNodeOrId) {
          var domNode;
          if(!domNodeOrId) {
            econda.debug.error("No dom node given in HtmlVideoTracker.setPlayer().");
            return this
          }
          domNode = DomHelper.element(domNodeOrId);
          if(!domNode) {
            econda.debug.error("No dom node found with given element id: " + domNodeOrId);
            return this
          }
          if(typeof domNode.tagName == "undefined" || domNode.tagName.toLowerCase() != "video") {
            econda.debug.error("Given element is not an html video tag in setPlayer().");
            return this
          }
          this.player = domNode;
          this.addEventListeners();
          return this
        };
        HtmlVideoTracker.prototype.updateTrackerData = function(property, value) {
          var _this = this;
          if(typeof property != "undefined") {
            this.trackerData[property] = value
          }
          if(this.tracker != null) {
            ObjectUtils.forEachOwnProperty(this.trackerData, function(value, key) {
              if(_this.tracker.get(key) === null) {
                _this.tracker.set(key, value)
              }
            });
            this.trackerData = {}
          }
          return this
        };
        HtmlVideoTracker.prototype.addEventListeners = function() {
          var cmp = this;
          var e = this.player;
          e.addEventListener("loadeddata", function() {
            cmp.handleLoadedDataEvent.apply(cmp, arguments)
          });
          e.addEventListener("seeking", function() {
            cmp.handleSeekingEvent.apply(cmp, arguments)
          });
          e.addEventListener("seeked", function() {
            cmp.handleSeekedEvent.apply(cmp, arguments)
          });
          e.addEventListener("play", function() {
            cmp.handlePlayEvent.apply(cmp, arguments)
          });
          e.addEventListener("pause", function() {
            cmp.handlePauseEvent.apply(cmp, arguments)
          });
          e.addEventListener("ended", function() {
            cmp.handleEndedEvent.apply(cmp, arguments)
          });
          return this
        };
        HtmlVideoTracker.prototype.getPreviewUriFromPlayer = function() {
          if(this.player) {
            var previewUri = new econda.net.Uri(this.player.currentSrc);
            if(previewUri.getScheme() !== econda.net.Uri.SCHEME_HTTPS) {
              previewUri.setScheme(econda.net.Uri.SCHEME_HTTPS)
            }
            return previewUri.toString()
          }
          return null
        };
        HtmlVideoTracker.prototype.getDurationFromPlayer = function() {
          if(this.player) {
            return Math.floor(this.player.duration)
          }
          return null
        };
        HtmlVideoTracker.prototype.getCurrentTimeFromPlayer = function() {
          if(this.player) {
            return this.player.currentTime
          }
          return null
        };
        HtmlVideoTracker.prototype.handleLoadedDataEvent = function(event) {
          econda.debug.log("got loadeddata event");
          this.updateTrackerData("duration", this.getDurationFromPlayer());
          this.updateTrackerData("previewUri", this.getPreviewUriFromPlayer());
          this.playerDataLoaded = true;
          if(this.tracker) {
            this.tracker.init()
          }
        };
        HtmlVideoTracker.prototype.handleSeekingEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got seeking event");
          if(this.cuedSeekedEvent) {
            clearTimeout(this.cuedSeekedEvent);
            this.cuedSeekedEvent = null
          }
          if(t) {
            t.setState("paused", this.getCurrentTimeFromPlayer())
          }
        };
        HtmlVideoTracker.prototype.handleSeekedEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got seeked event");
          if(t) {
            var pos = this.getCurrentTimeFromPlayer();
            this.cuedSeekedEvent = setTimeout(function() {
              t.setState("playing", pos)
            }, 250)
          }
        };
        HtmlVideoTracker.prototype.handlePlayEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got play event");
          if(t) {
            t.setState("playing", this.getCurrentTimeFromPlayer())
          }
        };
        HtmlVideoTracker.prototype.handlePauseEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got pause event");
          if(t) {
            t.setState("paused", this.getCurrentTimeFromPlayer())
          }
        };
        HtmlVideoTracker.prototype.handleEndedEvent = function(event) {
          var t = this.tracker;
          econda.debug.log("got ended event");
          if(t) {
            t.setState("stopped", this.getCurrentTimeFromPlayer())
          }
        };
        return HtmlVideoTracker
      }(econda.base.BaseClass);
      helper.HtmlVideoTracker = HtmlVideoTracker
    })(helper = media.helper || (media.helper = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var helper;
    (function(helper) {
      var DomHelper = econda.util.DomHelper;
      var YouTubeTracker = function(_super) {
        __extends(YouTubeTracker, _super);
        function YouTubeTracker(cfg) {
          _super.call(this);
          this._tracker = null;
          this._player = null;
          this._playerType = null;
          this._playerId = null;
          this.__defaultProperty = "player";
          if(cfg instanceof YouTubeTracker) {
            return cfg
          }
          this.initConfig(cfg)
        }
        YouTubeTracker.prototype.getTracker = function() {
          return this._tracker
        };
        YouTubeTracker.prototype.setTracker = function(tracker) {
          this._tracker = new econda.media.MediaTracker(tracker);
          return this
        };
        YouTubeTracker.prototype.getPlayer = function() {
          return this._player
        };
        YouTubeTracker.prototype.setPlayer = function(player) {
          var cmp = this, playerId, playerObject;
          if(typeof player == "string") {
            playerObject = DomHelper.element(player)
          }else {
            playerObject = player
          }
          this._player = playerObject;
          if(typeof playerObject.getIframe != "undefined") {
            this._playerType = "iframe";
            this._playerId = playerId = playerObject.getIframe().getAttribute("id")
          }else {
            this._playerId = playerId = playerObject.getAttribute("id")
          }
          YouTubeTracker.registeredTrackers[playerId] = this;
          if(this._playerType == "iframe") {
            playerObject.addEventListener("onReady", function() {
              cmp.handleReadyIframe.apply(cmp, arguments)
            });
            playerObject.addEventListener("onStateChange", function() {
              cmp.handleStateChangeIframe.apply(cmp, arguments)
            })
          }else {
            playerObject.addEventListener("onStateChange", "(function(newState){econda.media.helper.YouTubeTracker.registeredTrackers['" + playerId + "'].handleStateChange(newState);})")
          }
          return this
        };
        YouTubeTracker.prototype.handleStateChangeIframe = function(stateObj) {
          var cmp = this, tracker = cmp.getTracker(), newState;
          switch(stateObj.data) {
            case -1:
              break;
            case 0:
              newState = "stopped";
              break;
            case 1:
              newState = "playing";
              break;
            case 2:
              newState = "paused";
              break;
            case 3:
              break
          }
          if(tracker && newState) {
            tracker.setState(newState, cmp.getPlayer().getCurrentTime())
          }
          return this
        };
        YouTubeTracker.prototype.handleReadyIframe = function() {
          var cmp = this, tracker = cmp.getTracker(), player = cmp.getPlayer(), content, previewUri;
          if(!tracker) {
            tracker = new econda.media.MediaTracker;
            cmp.setTracker(tracker)
          }
          tracker.setDuration(player.getDuration());
          previewUri = player.getVideoUrl();
          tracker.setPreviewUri(previewUri.replace(/http:\/\//, "https://"));
          if(!tracker.getContent()) {
            tracker.setContent(location.pathname)
          }
          tracker.init()
        };
        YouTubeTracker.registeredTrackers = {};
        return YouTubeTracker
      }(econda.base.BaseClass);
      helper.YouTubeTracker = YouTubeTracker
    })(helper = media.helper || (media.helper = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));
var econda;
(function(econda) {
  var media;
  (function(media) {
    var helper;
    (function(helper) {
      var JwPlayerTracker = function(_super) {
        __extends(JwPlayerTracker, _super);
        function JwPlayerTracker(cfg) {
          _super.call(this);
          this._tracker = null;
          this._player = null;
          this.__defaultProperty = "player";
          this._ve = null;
          this._playerDataLoaded = false;
          this._trackerData = {};
          if(cfg instanceof JwPlayerTracker) {
            return cfg
          }
          this.initConfig(cfg)
        }
        JwPlayerTracker.prototype.getTracker = function() {
          return this._tracker
        };
        JwPlayerTracker.prototype.setTracker = function(tracker) {
          this._tracker = new econda.media.MediaTracker(tracker);
          this.updateTrackerData();
          return this
        };
        JwPlayerTracker.prototype.getPlayer = function() {
          return this._player
        };
        JwPlayerTracker.prototype.setPlayer = function(jwplayer) {
          if(!jwplayer) {
            econda.debug.error("No player object given.");
            return this
          }
          this._player = jwplayer;
          this.addEventListeners();
          return this
        };
        JwPlayerTracker.prototype.updateTrackerData = function(property, value) {
          if(typeof property != "undefined") {
            this._trackerData[property] = value
          }
          if(typeof this._tracker != "undefined") {
            this._tracker.set(this._trackerData)
          }
          return this
        };
        JwPlayerTracker.prototype.addEventListeners = function() {
          var cmp = this;
          var p = this._player;
          p.onReady(function() {
            cmp.handleReadyEvent.apply(cmp, arguments)
          });
          p.onPlay(function() {
            cmp.handlePlayEvent.apply(cmp, arguments)
          });
          p.onPause(function() {
            cmp.handlePauseEvent.apply(cmp, arguments)
          });
          p.onSeek(function() {
            cmp.handleSeekEvent.apply(cmp, arguments)
          });
          p.onComplete(function() {
            cmp.handleCompleteEvent.apply(cmp, arguments)
          });
          return this
        };
        JwPlayerTracker.prototype.handleReadyEvent = function() {
          econda.debug.log("got onReady event");
          this.updateTrackerData("duration", this._player.getDuration());
          this._playerDataLoaded = true;
          if(this._tracker) {
            this._tracker.init()
          }
        };
        JwPlayerTracker.prototype.handlePlayEvent = function() {
          var t = this._tracker, p = this._player;
          econda.debug.log("got play event");
          if(t) {
            t.setDuration(p.getDuration());
            t.setState("playing", p.getPosition())
          }
        };
        JwPlayerTracker.prototype.handleSeekEvent = function(args) {
          var t = this._tracker, p = this._player;
          econda.debug.log("got seek event to " + args.offset);
          if(t) {
            t.setState("playing", args.offset)
          }
        };
        JwPlayerTracker.prototype.handlePauseEvent = function(event) {
          var t = this._tracker;
          econda.debug.log("got pause event");
          if(t) {
            t.setState("paused", this._player.getPosition())
          }
        };
        JwPlayerTracker.prototype.handleCompleteEvent = function(event) {
          var t = this._tracker;
          econda.debug.log("got completed event");
          if(t) {
            t.setState("stopped", this._player.getPosition())
          }
        };
        return JwPlayerTracker
      }(econda.base.BaseClass);
      helper.JwPlayerTracker = JwPlayerTracker
    })(helper = media.helper || (media.helper = {}))
  })(media = econda.media || (econda.media = {}))
})(econda || (econda = {}));

