Construct Chips instance and set up overlay
@constructor
@param {Element} el
@param {Object} options
557994
function Chips(el, options) {
      _classCallCheck(this, Chips);

      var _this25 = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options));

      _this25.el.M_Chips = _this25;

      /**
       * Options for the modal
       * @member Chips#options
       * @prop {Array} data
       * @prop {String} placeholder
       * @prop {String} secondaryPlaceholder
       * @prop {Object} autocompleteOptions
       */
      _this25.options = $.extend({}, Chips.defaults, options);

      _this25.$el.addClass('chips input-field');
      _this25.chipsData = [];
      _this25.$chips = $();
      _this25._setupInput();
      _this25.hasAutocomplete = Object.keys(_this25.options.autocompleteOptions).length > 0;

      // Set input id
      if (!_this25.$input.attr('id')) {
        _this25.$input.attr('id', M.guid());
      }

      // Render initial chips
      if (_this25.options.data.length) {
        _this25.chipsData = _this25.options.data;
        _this25._renderChips(_this25.chipsData);
      }

      // Setup autocomplete if needed
      if (_this25.hasAutocomplete) {
        _this25._setupAutocomplete();
      }

      _this25._setPlaceholder();
      _this25._setupLabel();
      _this25._setupEventHandlers();
      return _this25;
    }
156895
function(element, options) {
        element = this.setElement(element);
        options = this.setOptions(options);

        if (!options.target || !options.marker) {
            throw new Error('A marker and target is required');
        }

        if (element.css('overflow') === 'auto') {
            this.container = element;
        }

        // Initialize events
        this.addEvents([
            ['scroll', 'container', $.throttle(this.onScroll.bind(this), options.throttle)],
            ['ready', 'document', 'onScroll']
        ]);

        this.initialize();

        // Gather markets and targets
        this.refresh();
    }
966587
def show_chips(options = {})
      options = {
        group:             nil,
        family:            nil,
        performance:       nil,
        part:              nil,
        chips_to_be_shown: ChipArray.new,
        creating_chip:     false
      }.update(options)
      chips_to_be_shown = options[:chips_to_be_shown]
      filter_hash(_chips, options[:group]).each do |_group, hash|
        filter_hash(hash, options[:family]).each do |_family, hash_|
          filter_hash(hash_, options[:performance]).each do |_performance, hash__|
            filter_hash(hash__, options[:part]).each do |_part, chip|
              chips_to_be_shown << chip
            end
          end
        end
      end
      # If no specs were found must check the possibility another search
      # should be started with mode set to :local or :global
      if chips_to_be_shown.empty?
        # Don't want to re-call this method if the callee is trying to create a spec and just wants to know
        # if there is a spec with the exact same options
        if options[:creating_chip] == false
          # Doesn't make sense to recall the method however if the mode is already set to :global or :local
          options[:chips_to_be_shown] = chips_to_be_shown
          Origen.log.debug "re-calling show_chips with options #{options}"
          return show_chips(options)
        end
        Origen.log.debug "Returning no chips for options #{options}"
        return nil
      elsif chips_to_be_shown.size == 1
        Origen.log.debug "returning one spec #{chips_to_be_shown.first.part_name}"
        return chips_to_be_shown.first
      else
        Origen.log.debug "returning an array of specs during initial search: #{chips_to_be_shown}"
        return chips_to_be_shown
      end
    end
865473
function(options) {
	events.EventEmitter.call(this); 	// inherit from EventEmitter
    	TRACE 		= options.log;
	IDX 		= options.idx;
	STATUS 		= options.status;
	HOST 		= options.host;
	REQUEST		= options.request;
	this.domoMQTT	= this.connect(HOST);
}
111134
function(element, options) {

    var $el = $(element);
    // React on every server/socket.io message.
    // If the element is defined with a data-react-on-event attribute
    // we take that as an eventType the user wants to be warned on this
    // element and we forward the event via jQuery events on $(this).
    this.initReactOnEveryMessage($el, options.reactOnMessage);

    // React on server message.
    // If the element is defined with a data-react-on-event attribute
    // we take that as an eventType the user wants to be warned on this
    // element and we forward the event via jQuery events on $(this).
    if (options.reactOnMessage) {
      this.initReactOnMessage($el, options.reactOnMessage);
    }
    // React on events originated from a data update in the backend
    // The user decides which object wants to be notified from with the
    // attribute data-react-on-dataupdate
    if (options.reactOnDataupdate) {
      this.initReactOnDataupdate($el, options.reactOnDataupdate);

    }
    if (options.reactOnUserinput) {
      // And make every form submit trigger the userinput message
      this.initReactOnUserInput($el, options.reactOnUserinput);
    }
    // react on routes updates using page.js 
    // the attribute  data-react-on-page holds the route 
    // that is passed to page(...);
    if (options.onRoute) {
      this.initOnRoute($el, options.onRoute);
    }
    $myelements.attachDefaultEventHandlers(element);
    // Render first time. empty. passing data- attributes
    // as locals to the EJS engine.
    // TODO: Should load from localstorage.
    // Take the innerHTML as a template.
    $myelements.updateElementScope(element);


    // Init page routing using page.js
    // multiple calls to page() are ignored 
    // so it's safe to callit on every element initialization
    page();
    $(element).trigger("init");
  }
78068
function(el) {
		return (el instanceof $ ? el : $(el)).find(this.makeSelector.apply(this, [].slice.call(arguments, 1)));
	}
642755
function Overlay(options) {
	if (!(this instanceof Overlay)) return new Overlay(options);

	Emitter.call(this);

	extend(this, options);

	if (!this.container) {
		this.container = document.body || document.documentElement;
	}

	//create overlay element
	this.element = document.createElement('div');
	this.element.classList.add('popoff-overlay');

	if (this.closable) {
		this.element.addEventListener('click', e => {
			this.hide();
		});
		this.element.classList.add('popoff-closable');
	}
}
365606
function(el, options) {
    var defaults = require('../utils/default-options')();

    if (typeof options === 'undefined') {
        options = {};
    }

    this.options = _.extend(defaults, options);
    this.color = this.options.color;

    this.xAccessor = this.options.xAccessor;
    this.yAccessor = this.options.yAccessor;

    this.el = el;

    this.selection = d3.select(el);

    this.transform = 0;

    this._data = [];

    this.area = d3.svg.area();

    this.zeroArea = d3.svg.area();

    this.series = this.selection.append('g')
        .attr('class', 'series')
        .attr('clip-path', 'url(#areaClip)');
}
295544
function createEngine(options = {}) {
    const isManaged = argv.GamePort || argv.StartPort || argv.LadderServer;

    const opts = {
        port: 5000,
        host : '127.0.0.1',
        launch: true,
        ...options,
    };

    // the ladder manager is launching this agent and it should override anything else
    if (isManaged) {
        opts.port = argv.GamePort;
        opts.host = argv.LadderServer;
    }
    
    opts.onGameEnd = opts.onGameEnd || NOOP;

    const world = World();
    const { actions: { _client } } = world.resources.get();

    /** @type {Engine} */
    const engine = {
        _totalLoopDelay: 0,
        _gameLeft: false,
        launcher,
        use(sys) {
            if (Array.isArray(sys)) {
                sys.forEach(s => this.systems.push(s));
            } else {
                this.systems.push(sys);
            }
        },
        systems: [],
        async connect() {
            if (opts.launch && !isManaged) {
                await launcher(opts);
            }

            const pingRes = await _client.connect(opts);

            /** 
             * @TODO: @node-sc2/proto should be throwing a custom error type here so we
             * can safely expect what the error shape is -
             */

            _client._ws.on('error', (e) => {
                // @ts-ignore
                debugEngine('Received error from transport layer:', e);
            });

            _client._ws.on('leftGame', () => {
                this._gameLeft = true;
            });

            return pingRes;
        },
        async runGame(map = '', players = []) {
            const player = players.find(p => !!p.agent);
            player.agent.settings.race = player.race;

            await this.createGame(map, players);
            return this.joinGame(player.agent);
        },
        async createGame(map = '', playerSetup = [], realtime = false) {
            if (isManaged) {
                debugEngine(`Engine tried to create a game, but is being managed by a ladder manager - skipping...`);
                return;
            }

            if (_client.status !== 1 && _client.status !== 5) {
                console.warn(`cannot create a game unless in "launched" or "ended" status, current status is ${StatusId[_client.status]}`);
                return;
            }

            let mapPath, battlenetMapName;

            if (map.includes('SC2Map')) {
                mapPath = map;
            } else {
                try {
                    mapPath = await findMap(map);
                } catch (e) {
                    battlenetMapName = map;
                }
            }

            /** @type {SC2APIProtocol.RequestCreateGame} */
            const game = {
                realtime,
                playerSetup,
            };

            if (mapPath) {
                game.localMap = { mapPath };
            } else {
                game.battlenetMapName = battlenetMapName;
            }

            // @FIXME: battlenet map cache sort of is broken

            debugEngine('CREATE GAME REQUEST: ', game);

            return _client.createGame(game);
        },
        async joinGame(agent, options = {}) {
            world.agent = agent;
            
            if (!agent.interface.raw) {
                throw new Error('`raw` is currently the only interface supported by this engine.');
            }

            switch (_client.status) {
                case 1:
                case 2: {
                    /** @type {SC2APIProtocol.RequestJoinGame} */
                    let participant = {
                        race: agent.settings && agent.settings.race || Race.RANDOM,
                        options: agent.interface,
                        ...options
                    };

                    if (isManaged) {
                        let sPort = /** @type {number} */ argv.StartPort + 1;

                        participant = {
                            ...participant,
                            sharedPort: sPort++,
                            serverPorts: {
                                gamePort: sPort++, 
                                basePort: sPort++,
                            },
                            clientPorts: [{
                                gamePort: sPort++,
                                basePort: sPort++,
                            }, {
                                gamePort: sPort++,
                                basePort: sPort++,
                            }]
                        };
                    }

                    // join the game and subsequently set the playerId for the bot
                    const joinGame = await _client.joinGame(participant);
                    debugEngine('JOIN GAME RES: ', joinGame);

                    agent.playerId = joinGame.playerId;

                    return this.firstRun();
                }

                case 3: {
                    console.warn(`cannot join lobby for a game already in progress, attemping to resync to existing game...`);

                    /* @FIXME how do we actually negotiate our player id here for resyncing? assuming 1 for debugging... */
                    agent.playerId = 1;

                    return this.firstRun();
                }

                default: {
                    throw new Error(`cannot join a game this engine didn't create unless in "launched" status, current status is ${StatusId[_client.status]}`);
                }

            }
        },
        async firstRun() {
            const { data, resources, agent } = world;

            /** @type {SC2APIProtocol.ResponseData} */
            const gameData = await _client.data({
                abilityId: true,
                unitTypeId: true,
                upgradeId: true,
                buffId: true,
                effectId: true,
            });

            ['abilities', 'units', 'upgrades', 'buffs', 'effects'].forEach((dataType) => {
                if (gameData[dataType]) data.set(dataType, gameData[dataType]);
            });

            [...this.systems, ...agent.systems, agent, debugSystem].forEach(system => system.setup(world));

            const { events } = resources.get();

            events.write({
                name: 'gameStart',
                type: 'all',
            });

            await this.dispatch();
            return this.runLoop();
        },
        onGameEnd(results) {
            if (!results || results.length <= 0) {
                console.warn('The game ended but there is no result data');
            }
            debugEngine(`Average step delay for this game: ${this._totalLoopDelay / world.resources.get().frame.getGameLoop()}`);
            // @TODO: have some option to configure auto-saving of replays
            return [world, results];
        },
        async runLoop() {
            const { events, frame } = world.resources.get();

            if (_client.status !== 3) {
                debugEngine('exiting loop, status no longer in game');
                this.onGameEnd(frame._result);
                // @TODO: check the frame to see if there happens to be some result data?
                throw new GameEndedError('Status no longer in game');
            }

            if (this._lastRequest) {
                this._loopDelay = hrtimeH(process.hrtime(this._lastRequest)).milliseconds;

                /** 
                 * I'd like to keep this here. I think as long as this api is aligned to providing a framework
                 * to get bots onto a ladder (like sc2ai, etc) or into tournaments - the user shouldn't be able
                 * to make a slow, resource draining bot without it being shoved in their face.
                 * 
                 * @TODO: maybe allow this to be configurable? not off... per se, but some threshhold.
                 */
                if (this._loopDelay / STEP_COUNT > 44.6) {
                    // console.warn(`WARNING! loop delay is ${this._loopDelay / STEP_COUNT}ms, greater than realtime`);
                }

                this._totalLoopDelay += this._loopDelay / STEP_COUNT;

                /**
                 * this was here for testing, but we could use it in the future to implement realtime
                 * 
                 * this.loopDelay = hrtimeH(process.hrtime(this.lastRequest)).milliseconds;
                 * const shouldDelay = calculateDelay(this.loopDelay);
                 * debug('delay frame: ', shouldDelay);
                 * //@ts-ignore bogus export default typing issue with `delay` package
                 * await delay(shouldDelay || 0);
                 */
            }

            this._lastRequest = process.hrtime();

            if (process.env.DELAY) {
                await Promise.delay(parseInt(process.env.DELAY, 10));
            }

            await _client.step({ count: STEP_COUNT });

            events.write({
                name: 'step',
                type: 'all',
                data: frame.getGameLoop() + STEP_COUNT,
            });

            try {
                await this.dispatch();
            } catch(e) {
                // @FIXME: this really shouldn't be branched via an error... but it was a quick fix
                if (e instanceof GameEndedError) {
                    // game over dude, we outtie
                    return this.onGameEnd(e.data);
                } else {
                    console.warn('An error of an unknown type has propegated up to the game loop', e);
                    throw e;
                }
            }

            return this.runLoop();
        },
        async dispatch() {
            /**
             * First, run all engine systems, and in series - the 'step' event propegates
             * all other events as well - starting with the frame system that handles digesting
             * the updated frame data.
             */
            const engineSystems = this.systems;
            await Promise.mapSeries(engineSystems, system => system(world)); // concurrency: 1
            
            /**
             * Next let the agent itself consume events -
             * 
             * @FIXME: this is a lot of duplicated logic from the system wrapper...
             * maybe an agent itself should just be a glorified system? alternative
             * is that it's time to break the dispatcher out into an actual entity
             * instead of just this engine function.
             */ 

            const { agent, resources } = world;
            const { events } = resources.get();
            const eventsWithHandlers = events.read(agent.readerId).filter(event => agent[`on${pascalCase(event.name)}`]);
            const handlerPromises = eventsWithHandlers.length > 0 ?
                eventsWithHandlers.map((event) => {
                    return agent[`on${pascalCase(event.name)}`](world, event.data, event)
                        .catch((err) => {
                            if (err instanceof NodeSC2Error) {
                                debugSilly(`Agent handler error: on${pascalCase(event.name)}: `, err);
                            } else {
                                console.warn(`Agent handler error: on${pascalCase(event.name)}: `);
                                debugEngine(err.message);
                                debugEngine(err.stack);
                            }
                        });
                }) :
                [];

            await Promise.all(handlerPromises);

            /**
             * @TODO: Should agent systems always be run concurrently? 
             * 
             * i fear making this configurable because it could cause massive 
             * perf issues with a ton of systems all potentially awaiting transport.
             * On the other hand - it would create a huge amount of flexibility to
             * allow systems to define their other system dependencies... such as acting
             * on entities with certain labels after they have been assigned/removed
             * by other systems that frame.
             */
            const { agent: { systems } } = world;
            await Promise.map(systems, system => system(world));

            // debug system runs last because it updates the in-client debug display
            return debugSystem(world);
        },
        _lastRequest: null,
    };

    engine.use([
        frameSystem,
        unitSystem,
        mapSystem,
    ]);

    return engine;
}
973611
function(el) {
            var self = this;

            self.callActions('beforeCacheDom', arguments);

            self.dom.el = el;

            self.callActions('afterCacheDom', arguments);
        }
419740
function Overlay(opts) {
  this.type = 'Overlay'
  this.enabled = true
  this.changed = new Signal()
  this.entity = null
  this.dirty = false
  this.x = 0
  this.y = 0
  this.width = 1
  this.height = 1
  this.texture = null
  this.alpha = 1
  this.set(opts)
}
97216
function(elem, parent_elem, options) {
		// DOM ELEMENTS
		this._el = {
			parent: {},
			container: {},
			button_backtostart: {},
			button_zoomin: {},
			button_zoomout: {},
			arrow: {},
			line: {},
			coverbar: {},
			grip: {}
		};

		this.collapsed = false;

		if (typeof elem === 'object') {
			this._el.container = elem;
		} else {
			this._el.container = TL.Dom.get(elem);
		}

		if (parent_elem) {
			this._el.parent = parent_elem;
		}

		//Options
		this.options = {
			width: 					600,
			height: 				600,
			duration: 				1000,
			ease: 					TL.Ease.easeInOutQuint,
			menubar_default_y: 		0
		};

		// Animation
		this.animator = {};

		// Merge Data and Options
		TL.Util.mergeData(this.options, options);

		this._initLayout();
		this._initEvents();
	}
1331926
function( el, e ) {
      var ajaxOptions = {},
        data = {},
        fieldName = el.name || el.id;

      if ( typeof this.remoteCache === 'undefined' ) this.remoteCache = {};

      data[ fieldName ] = this.tmp.val; // Set data
      // exends ajax options
      ajaxOptions = $.extend( true, {}, {
        data: data
      }, this.options.validators.remote[ this.tmp.remote ] || {} );

      // use $.param() function for generate specific cache key
      var cacheKey = $.param( ajaxOptions );

      // Check cache
      var cache = this.remoteCache[ cacheKey ];

      if ( typeof cache !== 'undefined' ) {
        switch( cache.state ) {
          case 'pending' : // pending means remote request not finished yet
            this.handler = 'pending'; // update handler and cache event type
            cache.event = e.type;
            break;
          case 'rejected' : // rejected means remote request could not be performed
            e.preventDefault(); // we have to break submit because of throw error
            throw new Error( cache.result.message );
          case 'resolved' : // resolved means remote request has done
            // Check to cache, if result is invalid, open an error window
            if ( cache.result.valid === false ) {
              this.addErrorClass( this.tmp.parent );
              this.window.open.call( this, el, cache.result.message );
            } else {
              this.addValidClass( this.tmp.parent );
            }
        }
      } else {
        // Abort if previous ajax request still running
        var _xhr = this.xhr[ fieldName ];
        if ( typeof _xhr !== 'undefined' && _xhr.state() === 'pending' ) _xhr.abort();
        // Start caching
        cache = this.remoteCache[ cacheKey ] = { state : 'pending', event : e.type };
        // make a remote request
        this.remoteRequest( ajaxOptions, cache, el, fieldName );
      }
    }
214756
function(options) {
        options = this.setOptions(options);
        this.element = this.createElement();

        // Generate loader elements
        this.loader = this.render(options.loaderTemplate).appendTo(this.element);
        this.message = this.loader.find(this.ns('message', 'loader'));

        if (options.showLoading) {
            this.message.html(Toolkit.messages.loading);
        }

        // Initialize
        this.initialize();
    }
874636
function (element, options) {
    this.element = $(element)
    this.options = $.extend(true, {}, this.options, options)
    this._init()
  }
917770
function buildLidFaces() {

			var start = verticesArray.length / 3;

			if ( bevelEnabled ) {

				var layer = 0; // steps + 1
				var offset = vlen * layer;

				// Bottom faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );

				}

				layer = steps + bevelSegments * 2;
				offset = vlen * layer;

				// Top faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );

				}

			} else {

				// Bottom faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 2 ], face[ 1 ], face[ 0 ] );

				}

				// Top faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );

				}

			}

			scope.addGroup( start, verticesArray.length / 3 - start, 0 );

		}
454317
function(element, options) {
        this.nodes = element = $(element); // Set to nodes so instances are unset during destroy()
        options = this.setOptions(options, element);

        // Create the toasts wrapper
        this.createWrapper()
            .addClass(options.position)
            .attr('role', 'log')
            .aria({
                relevant: 'additions',
                hidden: 'false'
            });

        this.initialize();
    }