'use strict';

var merge = require('merge-descriptors');
var utils = require('agentia-utilities');

var core = require('../core');
var helpers = require('../helpers/mixin');
var compatible = require('../compatible');
var init = require('./init');

function mixin(instance, compatibility) {
  compatibility = utils.isBoolean(compatibility) ? compatibility : false;
  merge(instance, core);
  merge(instance, helpers);
  init.call(instance);
  if (compatibility) {
    merge(instance, compatible);
  }
}

module.exports = mixin;

@@ -97,20 +97,98 @@
 );%0A%0Avar 
-core
+helpers = require('../helpers');%0Avar errors = require('../errors');%0A%0Avar coreMixin
  = requi
@@ -205,32 +205,37 @@
 e');%0Avar helpers
+Mixin
  = require('../h
@@ -264,16 +264,21 @@
 mpatible
+Mixin
  = requi
@@ -371,16 +371,142 @@
 lity) %7B%0A
+  helpers.checkMinArgs(arguments, 1);%0A%0A  if (!utils.isObject(instance)) %7B%0A    throw new errors.MustBeObject('instance');%0A  %7D%0A%0A
   compat
@@ -593,16 +593,21 @@
 ce, core
+Mixin
 );%0A  mer
@@ -626,16 +626,21 @@
  helpers
+Mixin
 );%0A  ini
@@ -710,16 +710,21 @@
 mpatible
+Mixin
 );%0A  %7D%0A%7D

add argument checks to .mixin()