/*
Documented, #mixin
972828
public static void mixin(final String funcName, final Function<String, String> func) {
        FUNCTIONS.put(funcName, func);
    }
629191
function (args) {
            this.type = "mixin";
            this.fn = function (service) {
                service.create = service[this.create];
                service.read = service[this.read];
                service.update = service[this.update];
                service.remove = service[this.remove];
            };
        }
460438
function mixinConstructor(source)
{
  var keys = Object.keys(source)
    , i    = keys.length
    ;

  while (i-- > 0) {
    this[keys[i]] = source[keys[i]];
  }
}
983538
function _wrapMixinMethod(method) {
    return function() { // ,... arguments
        var mixinInstance = _getMixinInstance.call(this, method.name);
        return method.apply(mixinInstance || this, arguments);
    };
}
141805
private Mixin parseMixin() {
        tokenizer.consumeExpectedKeyword(KEYWORD_MIXIN);
        Mixin mixin = new Mixin();
        parseName(mixin);
        parseParameterNames(mixin);
        parseMixinAttributes(mixin);

        return mixin;
    }
1344904
function(module) {
		if (gui.Type.isObject(module.mixin)) {
			gui.Spirit.mixin(module.mixin);
		}
		if (gui.Type.isArray(module.channel)) {
			gui.channel(module.channel);
		}
		if (gui.Type.isObject(module.plugin)) {
			gui.Object.each(module.plugin, function(prefix, Plugin) {
				if (gui.Type.isDefined(Plugin)) {
					gui.Spirit.plugin(prefix, Plugin);
				} else { // TODO: move check into gui.Spirit.plugin
					console.error("Undefined plugin for prefix: " + prefix);
				}
			});
		}
	}
840620
function(_mix) {
      if(_mix.$$chain) {
        this.chain(_mix.$$chain);
      } else if(typeof _mix === 'string') {
        this.mixin($injector.get(_mix));
      } else if(isArray(_mix)) {
        this.chain(_mix);
      } else if(isFunction(_mix)) {
        _mix.call(this.dsl, $injector);
      } else {
        this.dsl.describe(_mix);
      }
    }
1119351
function getArguments(name, mixin, obj) {
		let named = obj.named,
			ordered = obj.ordered,
			args = [],
			parameters;

		// Cache function parameter names
		if (! mixinArguments[name]) {
			mixinArguments[name] = mixin.toString()
				// Strip out quoted strings (stripping possible commas from parameters)
				.replace(/'((?:[^'\\])*)'|"((?:[^"\\])*)"/g, '')
				// Pull out parameters from function
				.match(/(?:function)?\s?.*?\s?\(([^)]*)\)/)[1]
				.split(',')
				.map(function(arg) {
					return arg.split('=')[0].trim();
				});
		}

		parameters = mixinArguments[name];

		Object.keys(named).forEach(key => {
			parameters.forEach((param, i) => {
				if (key === param) {
					args[i] = castArgument(named[key]);
				}
			});
		});

		ordered.forEach((arg, i) => {
			args[i] = castArgument(arg);
		});

		return args;
	}
979560
function mixSpecIntoComponent(Constructor, spec) {
	  if (!spec) {
	    if (false) {
	      var typeofSpec = typeof spec;
	      var isMixinValid = typeofSpec === 'object' && spec !== null;
	
	      process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
	    }
	
	    return;
	  }
	
	  !(typeof spec !== 'function') ?  false ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;
	  !!ReactElement.isValidElement(spec) ?  false ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;
	
	  var proto = Constructor.prototype;
	  var autoBindPairs = proto.__reactAutoBindPairs;
	
	  // By handling mixins before any other properties, we ensure the same
	  // chaining order is applied to methods with DEFINE_MANY policy, whether
	  // mixins are listed before or after these methods in the spec.
	  if (spec.hasOwnProperty(MIXINS_KEY)) {
	    RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
	  }
	
	  for (var name in spec) {
	    if (!spec.hasOwnProperty(name)) {
	      continue;
	    }
	
	    if (name === MIXINS_KEY) {
	      // We have already handled mixins in a special case above.
	      continue;
	    }
	
	    var property = spec[name];
	    var isAlreadyDefined = proto.hasOwnProperty(name);
	    validateMethodOverride(isAlreadyDefined, name);
	
	    if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
	      RESERVED_SPEC_KEYS[name](Constructor, property);
	    } else {
	      // Setup methods on prototype:
	      // The following member methods should not be automatically bound:
	      // 1. Expected ReactClass methods (in the "interface").
	      // 2. Overridden methods (that were mixed in).
	      var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
	      var isFunction = typeof property === 'function';
	      var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
	
	      if (shouldAutoBind) {
	        autoBindPairs.push(name, property);
	        proto[name] = property;
	      } else {
	        if (isAlreadyDefined) {
	          var specPolicy = ReactClassInterface[name];
	
	          // These cases should already be caught by validateMethodOverride.
	          !(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY')) ?  false ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;
	
	          // For methods which are defined more than once, call the existing
	          // methods before calling the new property, merging if appropriate.
	          if (specPolicy === 'DEFINE_MANY_MERGED') {
	            proto[name] = createMergedResultFunction(proto[name], property);
	          } else if (specPolicy === 'DEFINE_MANY') {
	            proto[name] = createChainedFunction(proto[name], property);
	          }
	        } else {
	          proto[name] = property;
	          if (false) {
	            // Add verbose displayName to the function, which helps when looking
	            // at profiling tools.
	            if (typeof property === 'function' && spec.displayName) {
	              proto[name].displayName = spec.displayName + '_' + name;
	            }
	          }
	        }
	      }
	    }
	  }
	}
1147845
function mixin(a, b) {
        if (a && b) {
            for (var k in b) {
                if (b.hasOwnProperty(k)) {
                    a[k] = b[k];
                }
            }
        }
        return a;
    }
974488
function addMixins(mixins, target, inherits, isNOTExtendingNative) {
    for (var
      source,
      init = [],
      i = 0; i < mixins.length; i++
    ) {
      source = transformMixin(mixins[i]);
      if (hOP.call(source, INIT)) {
        init.push(source[INIT]);
      }
      copyOwn(source, target, inherits, false, false, isNOTExtendingNative);
    }
    return init;
  }
603698
function mergeInner(base, mixin, mergeArrays) {
    if (base === null || typeof base !== 'object' || Array.isArray(base)) {
        throw new Error('base must be object');
    }
    if (mixin === null || typeof mixin !== 'object' || Array.isArray(mixin)) {
        throw new Error('mixin must be object');
    }
    Object.keys(mixin).forEach((name) => {
        mergeHelper(base, mixin, name, mergeArrays);
    });
}
357108
function mixin( key, val ){

        if ( typeof key === 'object' ){
            proto = extend(proto, key);
            proto.type = type;
            return;
        }

        if ( key !== 'type' && Physics.util.isFunction( val ) ){
            proto[ key ] = val;
        }
    }
105378
function mixpanelToPromise(callbackBasedFunction) {
		return Promise.fromCallback(function (callback) {
			if (isBrowser) {
				callbackBasedFunction(wrapBrowserCallback(callback))
			} else {
				callbackBasedFunction(callback)
			}
		})
	}
103993
function () {

        RemoteObjectTemplate.lazyTemplateLoad = this.config.lazyTemplateLoad;

            // Graph of mixins so we can process them at the end
        var mixinGraph = {};

        if (module.exports.objectTemplateInitialize) {
            module.exports.objectTemplateInitialize(RemoteObjectTemplate);
        }

        var objectTemplateSubClass = Object.create(RemoteObjectTemplate);
        var currentContext = {pass: 1};


        if (this.config.templateMode == 'typescript') {
        }
        else if (this.config.templateMode == 'auto') {

            var deferredExtends = [];
            RemoteObjectTemplate.__statics__ = {};

            usesV2ReturnPass1.prototype.mixin = function () {};

            usesV2ReturnPass1.prototype.extend = function(name) {
                this.extendedName = name;
                deferredExtends.push(this);

                return new usesV2ReturnPass1(name);
            };

            usesV2ReturnPass1.prototype.doExtend = function(futureTemplates) {
                if (!RemoteObjectTemplate.__dictionary__[this.baseName]) {
                    if (futureTemplates[this.baseName]) {
                        futureTemplates[this.baseName].doExtend(futureTemplates);
                    }

                    if (!RemoteObjectTemplate.__dictionary__[this.baseName]) {
                        throw Error('Attempt to extend ' + this.baseName + ' which was never defined; extendedName=' + this.extendedName);
                    }
                }

                if (!RemoteObjectTemplate.__dictionary__[this.extendedName]) {
                    var template = RemoteObjectTemplate.__dictionary__[this.baseName].extend(this.extendedName, {});
                }
            };

            for (var exp in module.exports || {}) {
                if (!exp.match(/_mixins/)) {
                    objectTemplateSubClass.create = function (name) {
                        var template = RemoteObjectTemplate.create(name, {});
                        var originalExtend = template.extend;

                        template.extend = function (name, props)  {
                            var template = RemoteObjectTemplate.__dictionary__[name];

                            if (template) {
                                template.mixin(props);
                            }
                            else {
                                template = originalExtend.call(this, name, props);
                            }

                            return template;
                        };

                        var originalMixin = template.mixin;

                        template.mixin = function () {
                            if (currentContext.pass === 2) {
                                if (arguments[0] && arguments[0].isObjectTemplate) {
                                    scheduleDeferredMixinProcessing(template, arguments[0]);
                                }
                                else {
                                    originalMixin.apply(template, arguments);
                                }
                            }
                        };

                        return template;
                    };

                    var initializerReturnValues = (module.exports[exp])(objectTemplateSubClass, usesV2Pass1);

                    recordStatics(initializerReturnValues);
                }
            }

                // Extended classes can't be processed until now when we know we have all the base classes defined
            var futureTemplates = {};

            for (var ix = 0; ix < deferredExtends.length; ++ix) {
                futureTemplates[deferredExtends[ix].extendedName] = deferredExtends[ix];
            }

            for (var ix = 0; ix < deferredExtends.length; ++ix) {
                deferredExtends[ix].doExtend(futureTemplates);
            }

            currentContext.pass = 2;

            var objectTemplateSubClass = Object.create(RemoteObjectTemplate);

            for (var exp in module.exports) {
                objectTemplateSubClass.create = function (name, props) {
                    if (RemoteObjectTemplate.__dictionary__[name.name || name]) {
                        RemoteObjectTemplate.__dictionary__[name.name || name].mixin(props);
                    }
                    else {
                        RemoteObjectTemplate.create(name, props);
                    }

                    return RemoteObjectTemplate.__dictionary__[name.name || name];
                };

                var initializerReturnValues;

                if (this.config && this.config.modules) {
                    initializerReturnValues = (module.exports[exp])(objectTemplateSubClass, usesV2Pass2, this.config.modules[exp.replace(/_mixins/, '')]);
                }
                else {
                    initializerReturnValues = (module.exports[exp])(objectTemplateSubClass, usesV2Pass2, null);
                }

                recordStatics(initializerReturnValues);
            }

            processDeferredMixins();

            for (var name in RemoteObjectTemplate.__dictionary__) {
                window[name] = RemoteObjectTemplate.__dictionary__[name];
            }

            for (var name in RemoteObjectTemplate.__statics__) {
                window[name] = RemoteObjectTemplate.__statics__[name];
            }
        }
        else {
            var requires = {};

            for (var exp in module.exports || {}) {
                if (!exp.match(/_mixins/)) {
                    var templates = (module.exports[exp])(RemoteObjectTemplate, function () {
                        return window;
                    });

                    requires[exp] = templates;

                    for (var template in  templates) {
                        window[template] = templates[template];
                    }
                }
            }

            var templates = flatten(requires);

            for (var exp in module.exports) {
                if (exp.match(/_mixins/)) {

                    if (this.config) {
                        templates = (module.exports[exp])(RemoteObjectTemplate, requires, this.config.modules[exp.replace(/_mixins/, '')], templates);
                    }
                    else {
                        templates = (module.exports[exp])(RemoteObjectTemplate, requires, null, templates);
                    }

                    for (var template in  templates) {
                        window[template] = templates[template];
                    }
                }
            }
        }

        RemoteObjectTemplate.performInjections();

        function flatten (requires) {
            var classes = {};

            for (var f in requires) {
                for (var c in requires[f]) {
                    classes[c] = requires[f][c];
                }
            }

            return classes;
        }

        function usesV2Pass1 (file, templateName, options) {
            var templateName = templateName || file.replace(/\.js$/, '').replace(/.*?[\/\\](\w)$/, '$1');
            var staticTemplate = RemoteObjectTemplate.__statics__[templateName];

            return staticTemplate || new usesV2ReturnPass1(templateName);
        }

        function usesV2Pass2 (file, templateName, options) {
            var templateName = templateName || file.replace(/\.js$/, '').replace(/.*?[\/\\](\w)$/, '$1');

            return RemoteObjectTemplate.__dictionary__[templateName] || RemoteObjectTemplate.__statics__[templateName];
        }

            // An object for creating request to extend classes to be done at thend of V2 pass1
        function usesV2ReturnPass1 (base) {
            this.baseName = base;
        }
        function scheduleDeferredMixinProcessing(template, mixinTemplate) {
            mixinGraph[template.__name__] =  mixinGraph[template.__name__] || {};
            mixinGraph[template.__name__][mixinTemplate.__name__] = true;
        }

        function processDeferredMixins() {

                // Go through each template that needs a mixin
            for (var rootMixin in mixinGraph) {
                processRootMixin(mixinGraph[rootMixin], rootMixin);
            }

            function processRootMixin(rootMixin, rootMixinTemplateName) {

                    // Go through each of the templates that needs to be mixed in
                for (var childMixin in rootMixin) {
                    processChildMixin(childMixin);
                }

                function processChildMixin(childMixinTemplateName) {

                        // that template that needs to be mixed in also needs mixins, process them first
                    if (mixinGraph[childMixinTemplateName]) {
                        processRootMixin(mixinGraph[childMixinTemplateName], childMixinTemplateName);
                        mixinGraph[childMixinTemplateName] = {};  // Make sure we don't process twice
                    }
                        // Now we can safely do the mixin
                    RemoteObjectTemplate.mixin(RemoteObjectTemplate.__dictionary__[rootMixinTemplateName],
                            RemoteObjectTemplate.__dictionary__[childMixinTemplateName]);
                }
            }
        }

        function recordStatics(initializerReturnValues) {
            for (var returnVariable in initializerReturnValues)                    {
                if (!RemoteObjectTemplate.__dictionary__[returnVariable]) {
                    if (RemoteObjectTemplate.__statics__[returnVariable]) {
                        var staticProps = Object.getOwnPropertyNames(RemoteObjectTemplate.__statics__[returnVariable]);
                        for (var sx = 0; sx < staticProps.length; ++sx) {
                            RemoteObjectTemplate.__statics__[returnVariable][staticProps[sx]] =
                                    initializerReturnValues[returnVariable][staticProps[sx]];
                        }
                    }
                    else {
                        RemoteObjectTemplate.__statics__[returnVariable] = initializerReturnValues[returnVariable];
                    }
                }
            }
        }

    }
1252732
private void startElementMixin(final Attributes attributes) {

        LOG.debug("Found mixin declaration");
        try {
            this.addMixin(this.nodeStack.peek(), attributes);
        } catch (final RepositoryException e) {
            throw new AssertionError("Could not add mixin type", e);
        }
    }
1125829
function addTo(name) {
            var indexName = name,
                match = name.match(/^([^\(]*)\s*\(([^\)]*)\)\s*/),
                params = match && match[2];
            name = match && match[1] || name;

            if (!index[indexName]) {
                if (params) {
                    // there can be no function calls here because of the regex match
                    /*jshint evil: true */
                    params = eval('[' + params + ']');
                }
                var mixin = _mixins[name],
                    checkAgain = false,
                    skip = false;

                if (mixin) {
                    if (typeof mixin === 'function') {
                        if (_initiatedOnce[name]) {
                            if (!initiatedOnce[name]) {
                                initiatedOnce[name] = [];
                                // add the placeholder so the mixin ends up in the right place
                                // we will replace all names with the appropriate mixins at the end
                                // (so we have all of the appropriate arguments)
                                mixin = name;
                            } else {
                                // but we only want to add it a single time
                                skip = true;
                            }
                            if (params) {
                                initiatedOnce[name].push(params);
                            }
                        } else {
                            mixin = mixin.apply(this, params || []);
                            checkAgain = true;
                        }
                    } else if (params) {
                        throw new Error('the mixin "' + name + '" does not support parameters');
                    }
                    get(_dependsOn[name], index, initiatedOnce, rtn);
                    get(_dependsInjected[name], index, initiatedOnce, rtn);

                    index[indexName] = true;
                    if (checkAgain) {
                        get([mixin], index, initiatedOnce, rtn);
                    } else if (!skip) {
                        checkForInlineMixins(mixin, rtn);
                        rtn.push(mixin);
                    }

                } else {
                    throw new Error('invalid mixin "' + name + '"');
                }
            }
        }