text: /*
  
  Copyright (C) 2011 by Andrea Giammarchi, @WebReflection
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  */
  
  /* jshint -W013 */
  /* jshint -W015 */
  /* jshint -W040 */
  /* jshint -W108 */
  /* jshint -W116 */
  
  (function (exports) {'use strict';
    //shared pointer
    var i;
    //shortcuts
    var defineProperty = Object.defineProperty, is = Object.is;
  
    /**
     * ES6 collection constructor
     * @return {Function} a collection class
     */
    function createCollection(proto, objectOnly){
      function Collection(a){
        if (!this || this.constructor !== Collection) return new Collection(a);
        this._keys = [];
        this._values = [];
        this._hash = {};
        this.objectOnly = objectOnly;
  
        //parse initial iterable argument passed
        if (a) init.call(this, a);
      }
  
      //define size for non object-only collections
      if (!objectOnly) {
        defineProperty(proto, 'size', {
          get: sharedSize
        });
      }
  
      //set prototype
      proto.constructor = Collection;
      Collection.prototype = proto;
  
      return Collection;
    }
  
  
    /** parse initial iterable argument passed */
    function init(a){
      //init Set argument, like `[1,2,3,{}]`
      if (this.add) {
        a.forEach(this.add, this);
      }
      //init Map argument like `[[1,2], [{}, 4]]`
      else {
        a.forEach(function (a) {
          this.set(a[0], a[1]);
        }, this);
      }
    }
  
  
    function sharedDelete(key) {
      if (this.has(key)) {
        if (typeof(key) === "string" || typeof(key) === "number") {
          this._hash[key] = undefined;
          return true;
        }
        else {
          this._keys.splice(i, 1);
          this._values.splice(i, 1);
        }
      }
      // Aurora here does it while Canary doesn't
      return -1 < i;
    }
  
    function sharedGet(key) {
      if (typeof(key) === "string" || typeof(key) === "number")
        return this._hash[key];
      return this.has(key) ? this._values[i] : undefined;
    }
  
    function has(list, key) {
      if (this.objectOnly && key !== Object(key))
        throw new TypeError("Invalid value used as weak collection key");
      if (typeof(key) === "string" || typeof(key) === "number") {
        return this._hash.hasOwnProperty(key);
      }
      //NaN passed
      if (key != key) for (i = list.length; i-- && !is(list[i], key););
      else i = list.indexOf(key);
      return -1 < i;
    }
  
    function setHas(value) {
      return has.call(this, this._values, value);
    }
  
    function mapHas(value) {
      return has.call(this, this._keys, value);
    }
  
    /** @chainable */
    function sharedSet(key, value) {
      if (typeof(key) === "string" || typeof(key) === "number") {
        this._hash[key] = value;
      }
      else if (this.has(key)) {
        this._values[i] = value;
      }
      else {
        this._values[this._keys.push(key) - 1] = value;
      }
      return this;
    }
  
    /** @chainable */
    function sharedAdd(value) {
      if (!this.has(value)) this._values.push(value);
      return this;
    }
  
    function sharedClear() {
      this._values.length = 0;
      this._hash = {};
    }
  
    /** keys, values, and iterate related methods */
    function sharedValues() {
      return this._values.slice().concat(Object.keys(this._hash).map(function (k) {
        return this._hash[k];
      }));
    }
  
    function sharedKeys() {
      return this._keys.slice().concat(Object.keys(this._hash));
    }
  
    function sharedSize() {
      return this._values.length;
    }
  
    function sharedForEach(callback, context) {
      var self = this;
      var values = self.sharedValues();
      self.sharedKeys().forEach(function(key, n){
        callback.call(context, values[n], key, self);
      });
    }
  
    function sharedSetIterate(callback, context) {
      var self = this;
      self._values.slice().forEach(function(value){
        callback.call(context, value, value, self);
      });
    }
  
  
    //Polyfill global objects
    if (typeof WeakMap == 'undefined') {
      exports.WeakMap = createCollection({
        // WeakMap#delete(key:void*):boolean
        'delete': sharedDelete,
        // WeakMap#clear():
        clear: sharedClear,
        // WeakMap#get(key:void*):void*
        get: sharedGet,
        // WeakMap#has(key:void*):boolean
        has: mapHas,
        // WeakMap#set(key:void*, value:void*):void
        set: sharedSet
      }, true);
    }
  
    if (typeof Map == 'undefined') {
      exports.Map = createCollection({
        // WeakMap#delete(key:void*):boolean
        'delete': sharedDelete,
        //:was Map#get(key:void*[, d3fault:void*]):void*
        // Map#has(key:void*):boolean
        has: mapHas,
        // Map#get(key:void*):boolean
        get: sharedGet,
        // Map#set(key:void*, value:void*):void
        set: sharedSet,
        // Map#keys(void):Array === not in specs
        keys: sharedKeys,
        // Map#values(void):Array === not in specs
        values: sharedValues,
        // Map#forEach(callback:Function, context:void*):void ==> callback.call(context, key, value, mapObject) === not in specs`
        forEach: sharedForEach,
        // Map#clear():
        clear: sharedClear
      });
    }
  
    if (typeof Set == 'undefined') {
      exports.Set = createCollection({
        // Set#has(value:void*):boolean
        has: setHas,
        // Set#add(value:void*):boolean
        add: sharedAdd,
        // Set#delete(key:void*):boolean
        'delete': sharedDelete,
        // Set#clear():
        clear: sharedClear,
        // Set#values(void):Array === not in specs
        values: sharedValues,
        // Set#forEach(callback:Function, context:void*):void ==> callback.call(context, value, index) === not in specs
        forEach: sharedSetIterate
      });
    }
  
    if (typeof WeakSet == 'undefined') {
      exports.WeakSet = createCollection({
        // WeakSet#delete(key:void*):boolean
        'delete': sharedDelete,
        // WeakSet#add(value:void*):boolean
        add: sharedAdd,
        // WeakSet#clear():
        clear: sharedClear,
        // WeakSet#has(value:void*):boolean
        has: setHas
      }, true);
    }
  
  })(typeof exports != 'undefined' && typeof global != 'undefined' ? global : window);
  