Skip to content

Instantly share code, notes, and snippets.

@vwasteels
Created January 19, 2016 20:03
Show Gist options
  • Save vwasteels/7cf86f5461c825405ade to your computer and use it in GitHub Desktop.
Save vwasteels/7cf86f5461c825405ade to your computer and use it in GitHub Desktop.
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var State = require('ampersand-state');
var Collection = require('ampersand-collection');
var Instance = State.extend({
props: {
id: 'number',
slug: 'string',
name: 'string'
},
collections: {
children: Collection.extend({ model: Instance })
}
});
var instance = new Instance({
id: 1,
slug: 'top',
name: 'Top',
children:
[
{
id: 2,
slug: 'child-1',
name: 'Child 1',
children:
[
{
id: 3,
slug: 'grand-child-3',
name: 'Grand Child 3'
}
]
}
]
});
console.log(instance.children instanceof Collection); //true
console.log(instance.children.models[0].children instanceof Collection) // false
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var assign=require("lodash.assign");var extend=function(protoProps){var parent=this;var child;var args=[].slice.call(arguments);if(protoProps&&protoProps.hasOwnProperty("constructor")){child=protoProps.constructor}else{child=function(){return parent.apply(this,arguments)}}assign(child,parent);var Surrogate=function(){this.constructor=child};Surrogate.prototype=parent.prototype;child.prototype=new Surrogate;if(protoProps){args.unshift(child.prototype);assign.apply(null,args)}child.__super__=parent.prototype;return child};module.exports=extend},{"lodash.assign":17}],2:[function(require,module,exports){if(typeof window!=="undefined"){window.ampersand=window.ampersand||{};window.ampersand["ampersand-events"]=window.ampersand["ampersand-events"]||[];window.ampersand["ampersand-events"].push("1.1.1")}var runOnce=require("lodash.once");var uniqueId=require("lodash.uniqueid");var keys=require("lodash.keys");var isEmpty=require("lodash.isempty");var each=require("lodash.foreach");var bind=require("lodash.bind");var assign=require("lodash.assign");var slice=Array.prototype.slice;var eventSplitter=/\s+/;var Events={on:function(name,callback,context){if(!eventsApi(this,"on",name,[callback,context])||!callback)return this;this._events||(this._events={});var events=this._events[name]||(this._events[name]=[]);events.push({callback:callback,context:context,ctx:context||this});return this},once:function(name,callback,context){if(!eventsApi(this,"once",name,[callback,context])||!callback)return this;var self=this;var once=runOnce(function(){self.off(name,once);callback.apply(this,arguments)});once._callback=callback;return this.on(name,once,context)},off:function(name,callback,context){var retain,ev,events,names,i,l,j,k;if(!this._events||!eventsApi(this,"off",name,[callback,context]))return this;if(!name&&!callback&&!context){this._events=void 0;return this}names=name?[name]:keys(this._events);for(i=0,l=names.length;i<l;i++){name=names[i];if(events=this._events[name]){this._events[name]=retain=[];if(callback||context){for(j=0,k=events.length;j<k;j++){ev=events[j];if(callback&&callback!==ev.callback&&callback!==ev.callback._callback||context&&context!==ev.context){retain.push(ev)}}}if(!retain.length)delete this._events[name]}}return this},trigger:function(name){if(!this._events)return this;var args=slice.call(arguments,1);if(!eventsApi(this,"trigger",name,args))return this;var events=this._events[name];var allEvents=this._events.all;if(events)triggerEvents(events,args);if(allEvents)triggerEvents(allEvents,arguments);return this},stopListening:function(obj,name,callback){var listeningTo=this._listeningTo;if(!listeningTo)return this;var remove=!name&&!callback;if(!callback&&typeof name==="object")callback=this;if(obj)(listeningTo={})[obj._listenId]=obj;for(var id in listeningTo){obj=listeningTo[id];obj.off(name,callback,this);if(remove||isEmpty(obj._events))delete this._listeningTo[id]}return this},createEmitter:function(obj){return assign(obj||{},Events)}};Events.bind=Events.on;Events.unbind=Events.off;var eventsApi=function(obj,action,name,rest){if(!name)return true;if(typeof name==="object"){for(var key in name){obj[action].apply(obj,[key,name[key]].concat(rest))}return false}if(eventSplitter.test(name)){var names=name.split(eventSplitter);for(var i=0,l=names.length;i<l;i++){obj[action].apply(obj,[names[i]].concat(rest))}return false}return true};var triggerEvents=function(events,args){var ev;var i=-1;var l=events.length;var a1=args[0];var a2=args[1];var a3=args[2];switch(args.length){case 0:while(++i<l)(ev=events[i]).callback.call(ev.ctx);return;case 1:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1);return;case 2:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2);return;case 3:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2,a3);return;default:while(++i<l)(ev=events[i]).callback.apply(ev.ctx,args);return}};var listenMethods={listenTo:"on",listenToOnce:"once"};each(listenMethods,function(implementation,method){Events[method]=function(obj,name,callback,run){var listeningTo=this._listeningTo||(this._listeningTo={});var id=obj._listenId||(obj._listenId=uniqueId("l"));listeningTo[id]=obj;if(!callback&&typeof name==="object")callback=this;obj[implementation](name,callback,this);return this}});Events.listenToAndRun=function(obj,name,callback){Events.listenTo.apply(this,arguments);if(!callback&&typeof name==="object")callback=this;callback.apply(this);return this};module.exports=Events},{"lodash.assign":17,"lodash.bind":27,"lodash.foreach":3,"lodash.isempty":7,"lodash.keys":11,"lodash.once":14,"lodash.uniqueid":16}],3:[function(require,module,exports){var arrayEach=require("lodash._arrayeach"),baseEach=require("lodash._baseeach"),bindCallback=require("lodash._bindcallback"),isArray=require("lodash.isarray");function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return typeof iteratee=="function"&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}var forEach=createForEach(arrayEach,baseEach);module.exports=forEach},{"lodash._arrayeach":4,"lodash._baseeach":5,"lodash._bindcallback":6,"lodash.isarray":31}],4:[function(require,module,exports){function arrayEach(array,iteratee){var index=-1,length=array.length;while(++index<length){if(iteratee(array[index],index,array)===false){break}}return array}module.exports=arrayEach},{}],5:[function(require,module,exports){var keys=require("lodash.keys");var MAX_SAFE_INTEGER=9007199254740991;var baseEach=createBaseEach(baseForOwn);var baseFor=createBaseFor();function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseProperty(key){return function(object){return object==null?undefined:object[key]}}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length)){return eachFunc(collection,iteratee)}var index=fromRight?length:-1,iterable=toObject(collection);while(fromRight?index--:++index<length){if(iteratee(iterable[index],index,iterable)===false){break}}return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;while(fromRight?index--:++index<length){var key=props[index];if(iteratee(iterable[key],key,iterable)===false){break}}return object}}var getLength=baseProperty("length");function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseEach},{"lodash.keys":11}],6:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(thisArg===undefined){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],7:[function(require,module,exports){var isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray"),isFunction=require("lodash.isfunction"),isString=require("lodash.isstring"),keys=require("lodash.keys");function isObjectLike(value){return!!value&&typeof value=="object"}var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isEmpty(value){if(value==null){return true}if(isArrayLike(value)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))){return!value.length}return!keys(value).length}module.exports=isEmpty},{"lodash.isarguments":8,"lodash.isarray":31,"lodash.isfunction":9,"lodash.isstring":10,"lodash.keys":11}],8:[function(require,module,exports){(function(global){var MAX_SAFE_INTEGER=9007199254740991;var argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]";var objectProto=global.Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objectToString=objectProto.toString;var propertyIsEnumerable=objectProto.propertyIsEnumerable;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArguments(value){return isArrayLikeObject(value)&&hasOwnProperty.call(value,"callee")&&(!propertyIsEnumerable.call(value,"callee")||objectToString.call(value)==argsTag)}function isArrayLike(value){return value!=null&&!(typeof value=="function"&&isFunction(value))&&isLength(getLength(value))}function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isObjectLike(value){return!!value&&typeof value=="object"}module.exports=isArguments}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],9:[function(require,module,exports){(function(global){var funcTag="[object Function]",genTag="[object GeneratorFunction]";var objectProto=global.Object.prototype;var objectToString=objectProto.toString;function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isFunction}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],10:[function(require,module,exports){var stringTag="[object String]";function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var objToString=objectProto.toString;function isString(value){return typeof value=="string"||isObjectLike(value)&&objToString.call(value)==stringTag}module.exports=isString},{}],11:[function(require,module,exports){var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var nativeKeys=getNative(Object,"keys");var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||typeof object!="function"&&isArrayLike(object)){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keys},{"lodash._getnative":12,"lodash.isarguments":13,"lodash.isarray":31}],12:[function(require,module,exports){var funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=getNative},{}],13:[function(require,module,exports){module.exports=require(8)},{}],14:[function(require,module,exports){var before=require("lodash.before");function once(func){return before(2,func)}module.exports=once},{"lodash.before":15}],15:[function(require,module,exports){var FUNC_ERROR_TEXT="Expected a function";function before(n,func){var result;if(typeof func!="function"){if(typeof n=="function"){var temp=n;n=func;func=temp}else{throw new TypeError(FUNC_ERROR_TEXT)}}return function(){if(--n>0){result=func.apply(this,arguments)}if(n<=1){func=undefined}return result}}module.exports=before},{}],16:[function(require,module,exports){(function(global){var INFINITY=1/0;var symbolTag="[object Symbol]";var objectProto=global.Object.prototype;var idCounter=0;var objectToString=objectProto.toString;var _Symbol=global.Symbol;var symbolProto=_Symbol?_Symbol.prototype:undefined,symbolToString=_Symbol?symbolProto.toString:undefined;function isObjectLike(value){return!!value&&typeof value=="object"}function isSymbol(value){return typeof value=="symbol"||isObjectLike(value)&&objectToString.call(value)==symbolTag}function toString(value){if(typeof value=="string"){return value}if(value==null){return""}if(isSymbol(value)){return _Symbol?symbolToString.call(value):""}var result=value+"";return result=="0"&&1/value==-INFINITY?"-0":result}function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id}module.exports=uniqueId}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],17:[function(require,module,exports){var baseAssign=require("lodash._baseassign"),createAssigner=require("lodash._createassigner"),keys=require("lodash.keys");function assignWith(object,source,customizer){var index=-1,props=keys(source),length=props.length;while(++index<length){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);if((result===result?result!==value:value===value)||value===undefined&&!(key in object)){object[key]=result}}return object}var assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)});module.exports=assign},{"lodash._baseassign":18,"lodash._createassigner":20,"lodash.keys":24}],18:[function(require,module,exports){var baseCopy=require("lodash._basecopy"),keys=require("lodash.keys");function baseAssign(object,source){return source==null?object:baseCopy(source,keys(source),object)}module.exports=baseAssign},{"lodash._basecopy":19,"lodash.keys":24}],19:[function(require,module,exports){function baseCopy(source,props,object){object||(object={});var index=-1,length=props.length;while(++index<length){var key=props[index];object[key]=source[key]}return object}module.exports=baseCopy},{}],20:[function(require,module,exports){var bindCallback=require("lodash._bindcallback"),isIterateeCall=require("lodash._isiterateecall"),restParam=require("lodash.restparam");function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=object==null?0:sources.length,customizer=length>2?sources[length-2]:undefined,guard=length>2?sources[2]:undefined,thisArg=length>1?sources[length-1]:undefined;if(typeof customizer=="function"){customizer=bindCallback(customizer,thisArg,5);length-=2}else{customizer=typeof thisArg=="function"?thisArg:undefined;length-=customizer?1:0}if(guard&&isIterateeCall(sources[0],sources[1],guard)){customizer=length<3?undefined:customizer;length=1}while(++index<length){var source=sources[index];if(source){assigner(object,source,customizer)}}return object})}module.exports=createAssigner},{"lodash._bindcallback":21,"lodash._isiterateecall":22,"lodash.restparam":23}],21:[function(require,module,exports){module.exports=require(6)},{}],22:[function(require,module,exports){var reIsUint=/^\d+$/;var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isIterateeCall(value,index,object){if(!isObject(object)){return false}var type=typeof index;if(type=="number"?isArrayLike(object)&&isIndex(index,object.length):type=="string"&&index in object){var other=object[index];return value===value?value===other:other!==other}return false}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isIterateeCall},{}],23:[function(require,module,exports){var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max;function restParam(func,start){if(typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}start=nativeMax(start===undefined?func.length-1:+start||0,0);return function(){var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);while(++index<length){rest[index]=args[start+index]}switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);index=-1;while(++index<start){otherArgs[index]=args[index]}otherArgs[start]=rest;return func.apply(this,otherArgs)}}module.exports=restParam},{}],24:[function(require,module,exports){module.exports=require(11)},{"lodash._getnative":25,"lodash.isarguments":26,"lodash.isarray":31}],25:[function(require,module,exports){module.exports=require(12)},{}],26:[function(require,module,exports){module.exports=require(8)},{}],27:[function(require,module,exports){var createWrapper=require("lodash._createwrapper"),replaceHolders=require("lodash._replaceholders"),restParam=require("lodash.restparam");var BIND_FLAG=1,PARTIAL_FLAG=32;var bind=restParam(function(func,thisArg,partials){var bitmask=BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,bind.placeholder);bitmask|=PARTIAL_FLAG}return createWrapper(func,bitmask,thisArg,partials,holders)});bind.placeholder={};module.exports=bind},{"lodash._createwrapper":28,"lodash._replaceholders":29,"lodash.restparam":30}],28:[function(require,module,exports){(function(global){var BIND_FLAG=1,BIND_KEY_FLAG=2,CURRY_BOUND_FLAG=4,CURRY_FLAG=8,CURRY_RIGHT_FLAG=16,PARTIAL_FLAG=32,PARTIAL_RIGHT_FLAG=64,ARY_FLAG=128,FLIP_FLAG=512;var FUNC_ERROR_TEXT="Expected a function";var INFINITY=1/0,MAX_SAFE_INTEGER=9007199254740991,MAX_INTEGER=1.7976931348623157e308,NAN=0/0;var PLACEHOLDER="__lodash_placeholder__";var funcTag="[object Function]",genTag="[object GeneratorFunction]";var reTrim=/^\s+|\s+$/g;var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;var reIsBinary=/^0b[01]+$/i;var reIsOctal=/^0o[0-7]+$/i;var reIsUint=/^(?:0|[1-9]\d*)$/;var freeParseInt=parseInt;function apply(func,thisArg,args){var length=args?args.length:0;switch(length){case 0:return func.call(thisArg);case 1:return func.call(thisArg,args[0]);case 2:return func.call(thisArg,args[0],args[1]);case 3:return func.call(thisArg,args[0],args[1],args[2])}return func.apply(thisArg,args)}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){if(array[index]===placeholder){array[index]=PLACEHOLDER;result[++resIndex]=index}}return result}var objectProto=global.Object.prototype;var objectToString=objectProto.toString;var nativeMax=Math.max,nativeMin=Math.min;var baseCreate=function(){function object(){}return function(prototype){if(isObject(prototype)){object.prototype=prototype;var result=new object;object.prototype=undefined}return result||{}}}();function composeArgs(args,partials,holders){var holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),leftIndex=-1,leftLength=partials.length,result=Array(leftLength+argsLength);while(++leftIndex<leftLength){result[leftIndex]=partials[leftIndex]}while(++argsIndex<holdersLength){result[holders[argsIndex]]=args[argsIndex]}while(argsLength--){result[leftIndex++]=args[argsIndex++]}return result}function composeArgsRight(args,partials,holders){var holdersIndex=-1,holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),rightIndex=-1,rightLength=partials.length,result=Array(argsLength+rightLength);while(++argsIndex<argsLength){result[argsIndex]=args[argsIndex]}var offset=argsIndex;while(++rightIndex<rightLength){result[offset+rightIndex]=partials[rightIndex]}while(++holdersIndex<holdersLength){result[offset+holders[holdersIndex]]=args[argsIndex++]}return result}function copyArray(source,array){var index=-1,length=source.length;array||(array=Array(length));while(++index<length){array[index]=source[index]}return array}function createBaseWrapper(func,bitmask,thisArg){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var fn=this&&this!==global&&this instanceof wrapper?Ctor:func;return fn.apply(isBind?thisArg:this,arguments)}return wrapper}function createCtorWrapper(Ctor){return function(){var args=arguments;switch(args.length){case 0:return new Ctor;case 1:return new Ctor(args[0]);case 2:return new Ctor(args[0],args[1]);case 3:return new Ctor(args[0],args[1],args[2]);case 4:return new Ctor(args[0],args[1],args[2],args[3]);case 5:return new Ctor(args[0],args[1],args[2],args[3],args[4]);case 6:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5]);case 7:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5],args[6])}var thisBinding=baseCreate(Ctor.prototype),result=Ctor.apply(thisBinding,args);return isObject(result)?result:thisBinding}}function createCurryWrapper(func,bitmask,arity){var Ctor=createCtorWrapper(func);function wrapper(){var length=arguments.length,index=length,args=Array(length),fn=this&&this!==global&&this instanceof wrapper?Ctor:func,placeholder=wrapper.placeholder;while(index--){args[index]=arguments[index]}var holders=length<3&&args[0]!==placeholder&&args[length-1]!==placeholder?[]:replaceHolders(args,placeholder);length-=holders.length;return length<arity?createRecurryWrapper(func,bitmask,createHybridWrapper,placeholder,undefined,args,holders,undefined,undefined,arity-length):apply(fn,this,args)}return wrapper}function createHybridWrapper(func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity){var isAry=bitmask&ARY_FLAG,isBind=bitmask&BIND_FLAG,isBindKey=bitmask&BIND_KEY_FLAG,isCurry=bitmask&CURRY_FLAG,isCurryRight=bitmask&CURRY_RIGHT_FLAG,isFlip=bitmask&FLIP_FLAG,Ctor=isBindKey?undefined:createCtorWrapper(func);function wrapper(){var length=arguments.length,index=length,args=Array(length);while(index--){args[index]=arguments[index]}if(partials){args=composeArgs(args,partials,holders)}if(partialsRight){args=composeArgsRight(args,partialsRight,holdersRight)}if(isCurry||isCurryRight){var placeholder=wrapper.placeholder,argsHolders=replaceHolders(args,placeholder);length-=argsHolders.length;if(length<arity){return createRecurryWrapper(func,bitmask,createHybridWrapper,placeholder,thisArg,args,argsHolders,argPos,ary,arity-length)}}var thisBinding=isBind?thisArg:this,fn=isBindKey?thisBinding[func]:func;if(argPos){args=reorder(args,argPos)}else if(isFlip&&args.length>1){args.reverse()}if(isAry&&ary<args.length){args.length=ary}if(this&&this!==global&&this instanceof wrapper){fn=Ctor||createCtorWrapper(fn)}return fn.apply(thisBinding,args)}return wrapper}function createPartialWrapper(func,bitmask,thisArg,partials){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength),fn=this&&this!==global&&this instanceof wrapper?Ctor:func;while(++leftIndex<leftLength){args[leftIndex]=partials[leftIndex]}while(argsLength--){args[leftIndex++]=arguments[++argsIndex]}return apply(fn,isBind?thisArg:this,args)}return wrapper}function createRecurryWrapper(func,bitmask,wrapFunc,placeholder,thisArg,partials,holders,argPos,ary,arity){var isCurry=bitmask&CURRY_FLAG,newArgPos=argPos?copyArray(argPos):undefined,newsHolders=isCurry?holders:undefined,newHoldersRight=isCurry?undefined:holders,newPartials=isCurry?partials:undefined,newPartialsRight=isCurry?undefined:partials;bitmask|=isCurry?PARTIAL_FLAG:PARTIAL_RIGHT_FLAG;bitmask&=~(isCurry?PARTIAL_RIGHT_FLAG:PARTIAL_FLAG);if(!(bitmask&CURRY_BOUND_FLAG)){bitmask&=~(BIND_FLAG|BIND_KEY_FLAG)}var result=wrapFunc(func,bitmask,thisArg,newPartials,newsHolders,newPartialsRight,newHoldersRight,newArgPos,ary,arity);result.placeholder=placeholder;return result}function createWrapper(func,bitmask,thisArg,partials,holders,argPos,ary,arity){var isBindKey=bitmask&BIND_KEY_FLAG;if(!isBindKey&&typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}var length=partials?partials.length:0;if(!length){bitmask&=~(PARTIAL_FLAG|PARTIAL_RIGHT_FLAG);partials=holders=undefined}ary=ary===undefined?ary:nativeMax(toInteger(ary),0);arity=arity===undefined?arity:toInteger(arity);length-=holders?holders.length:0;if(bitmask&PARTIAL_RIGHT_FLAG){var partialsRight=partials,holdersRight=holders;partials=holders=undefined}var newData=[func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity];func=newData[0];bitmask=newData[1];thisArg=newData[2];partials=newData[3];holders=newData[4];arity=newData[9]=newData[9]==null?isBindKey?0:func.length:nativeMax(newData[9]-length,0);if(!arity&&bitmask&(CURRY_FLAG|CURRY_RIGHT_FLAG)){bitmask&=~(CURRY_FLAG|CURRY_RIGHT_FLAG)}if(!bitmask||bitmask==BIND_FLAG){var result=createBaseWrapper(func,bitmask,thisArg)}else if(bitmask==CURRY_FLAG||bitmask==CURRY_RIGHT_FLAG){result=createCurryWrapper(func,bitmask,arity)}else if((bitmask==PARTIAL_FLAG||bitmask==(BIND_FLAG|PARTIAL_FLAG))&&!holders.length){result=createPartialWrapper(func,bitmask,thisArg,partials)}else{result=createHybridWrapper.apply(undefined,newData)}return result}function reorder(array,indexes){var arrLength=array.length,length=nativeMin(indexes.length,arrLength),oldArray=copyArray(array);while(length--){var index=indexes[length];array[length]=isIndex(index,arrLength)?oldArray[index]:undefined}return array}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function toInteger(value){if(!value){return value===0?value:0}value=toNumber(value);if(value===INFINITY||value===-INFINITY){var sign=value<0?-1:1;return sign*MAX_INTEGER}var remainder=value%1;return value===value?remainder?value-remainder:value:0}function toNumber(value){if(isObject(value)){var other=isFunction(value.valueOf)?value.valueOf():value;value=isObject(other)?other+"":other}if(typeof value!="string"){return value===0?value:+value}value=value.replace(reTrim,"");var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}module.exports=createWrapper}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],29:[function(require,module,exports){var PLACEHOLDER="__lodash_placeholder__";function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){if(array[index]===placeholder){array[index]=PLACEHOLDER;result[++resIndex]=index}}return result}module.exports=replaceHolders},{}],30:[function(require,module,exports){module.exports=require(23)},{}],31:[function(require,module,exports){var arrayTag="[object Array]",funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var nativeIsArray=getNative(Array,"isArray");var MAX_SAFE_INTEGER=9007199254740991;function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=isArray},{}],"ampersand-collection":[function(require,module,exports){var AmpersandEvents=require("ampersand-events");var classExtend=require("ampersand-class-extend");var isArray=require("lodash.isarray");var bind=require("lodash.bind");var assign=require("lodash.assign");var slice=[].slice;
function Collection(models,options){options||(options={});if(options.model)this.model=options.model;if(options.comparator)this.comparator=options.comparator;if(options.parent)this.parent=options.parent;if(!this.mainIndex){var idAttribute=this.model&&this.model.prototype&&this.model.prototype.idAttribute;this.mainIndex=idAttribute||"id"}this._reset();this.initialize.apply(this,arguments);if(models)this.reset(models,assign({silent:true},options))}assign(Collection.prototype,AmpersandEvents,{initialize:function(){},isModel:function(model){return this.model&&model instanceof this.model},add:function(models,options){return this.set(models,assign({merge:false,add:true,remove:false},options))},parse:function(res,options){return res},serialize:function(){return this.map(function(model){if(model.serialize){return model.serialize()}else{var out={};assign(out,model);delete out.collection;return out}})},toJSON:function(){return this.serialize()},set:function(models,options){options=assign({add:true,remove:true,merge:true},options);if(options.parse)models=this.parse(models,options);var singular=!isArray(models);models=singular?models?[models]:[]:models.slice();var id,model,attrs,existing,sort,i,length;var at=options.at;var sortable=this.comparator&&at==null&&options.sort!==false;var sortAttr="string"===typeof this.comparator?this.comparator:null;var toAdd=[],toRemove=[],modelMap={};var add=options.add,merge=options.merge,remove=options.remove;var order=!sortable&&add&&remove?[]:false;var targetProto=this.model&&this.model.prototype||Object.prototype;for(i=0,length=models.length;i<length;i++){attrs=models[i]||{};if(this.isModel(attrs)){id=model=attrs}else if(targetProto.generateId){id=targetProto.generateId(attrs)}else{id=attrs[this.mainIndex];if(id===undefined&&this._isDerivedIndex(targetProto)){id=targetProto._derived[this.mainIndex].fn.call(attrs)}}if(existing=this.get(id)){if(remove)modelMap[existing.cid||existing[this.mainIndex]]=true;if(merge){attrs=attrs===model?model.attributes:attrs;if(options.parse)attrs=existing.parse(attrs,options);if(existing.set){existing.set(attrs,options);if(sortable&&!sort&&existing.hasChanged(sortAttr))sort=true}else{assign(existing,attrs)}}models[i]=existing}else if(add){model=models[i]=this._prepareModel(attrs,options);if(!model)continue;toAdd.push(model);this._addReference(model,options)}model=existing||model;if(!model)continue;if(order&&(model.isNew&&model.isNew()||!model[this.mainIndex]||!modelMap[model.cid||model[this.mainIndex]]))order.push(model);modelMap[model[this.mainIndex]]=true}if(remove){for(i=0,length=this.length;i<length;i++){model=this.models[i];if(!modelMap[model.cid||model[this.mainIndex]])toRemove.push(model)}if(toRemove.length)this.remove(toRemove,options)}if(toAdd.length||order&&order.length){if(sortable)sort=true;if(at!=null){for(i=0,length=toAdd.length;i<length;i++){this.models.splice(at+i,0,toAdd[i])}}else{var orderedModels=order||toAdd;for(i=0,length=orderedModels.length;i<length;i++){this.models.push(orderedModels[i])}}}if(sort)this.sort({silent:true});if(!options.silent){for(i=0,length=toAdd.length;i<length;i++){model=toAdd[i];if(model.trigger){model.trigger("add",model,this,options)}else{this.trigger("add",model,this,options)}}if(sort||order&&order.length)this.trigger("sort",this,options)}return singular?models[0]:models},get:function(query,indexName){if(query==null)return;var index=this._indexes[indexName||this.mainIndex];return index&&(index[query]||index[query[this.mainIndex]])||this._indexes.cid[query]||this._indexes.cid[query.cid]},at:function(index){return this.models[index]},remove:function(models,options){var singular=!isArray(models);var i,length,model,index;models=singular?[models]:slice.call(models);options||(options={});for(i=0,length=models.length;i<length;i++){model=models[i]=this.get(models[i]);if(!model)continue;this._deIndex(model);index=this.models.indexOf(model);this.models.splice(index,1);if(!options.silent){options.index=index;if(model.trigger){model.trigger("remove",model,this,options)}else{this.trigger("remove",model,this,options)}}this._removeReference(model,options)}return singular?models[0]:models},reset:function(models,options){options||(options={});for(var i=0,length=this.models.length;i<length;i++){this._removeReference(this.models[i],options)}options.previousModels=this.models;this._reset();models=this.add(models,assign({silent:true},options));if(!options.silent)this.trigger("reset",this,options);return models},sort:function(options){var self=this;if(!this.comparator)throw new Error("Cannot sort a set without a comparator");options||(options={});if(typeof this.comparator==="string"){this.models.sort(function(left,right){if(left.get){left=left.get(self.comparator);right=right.get(self.comparator)}else{left=left[self.comparator];right=right[self.comparator]}if(left>right||left===void 0)return 1;if(left<right||right===void 0)return-1;return 0})}else if(this.comparator.length===1){this.models.sort(function(left,right){left=self.comparator(left);right=self.comparator(right);if(left>right||left===void 0)return 1;if(left<right||right===void 0)return-1;return 0})}else{this.models.sort(bind(this.comparator,this))}if(!options.silent)this.trigger("sort",this,options);return this},_reset:function(){var list=slice.call(this.indexes||[]);var i=0;list.push(this.mainIndex);list.push("cid");var l=list.length;this.models=[];this._indexes={};for(;i<l;i++){this._indexes[list[i]]={}}},_prepareModel:function(attrs,options){if(!this.model)return attrs;if(this.isModel(attrs)){if(!attrs.collection)attrs.collection=this;return attrs}else{options=options?assign({},options):{};options.collection=this;var model=new this.model(attrs,options);if(!model.validationError)return model;this.trigger("invalid",this,model.validationError,options);return false}},_deIndex:function(model,attribute,value){var indexVal;if(attribute!==undefined){if(undefined===this._indexes[attribute])throw new Error("Given attribute is not an index");delete this._indexes[attribute][value];return}for(attribute in this._indexes){indexVal=model.hasOwnProperty(attribute)?model[attribute]:model.get&&model.get(attribute);delete this._indexes[attribute][indexVal]}},_index:function(model,attribute){var indexVal;if(attribute!==undefined){if(undefined===this._indexes[attribute])throw new Error("Given attribute is not an index");indexVal=model[attribute]||model.get&&model.get(attribute);if(indexVal)this._indexes[attribute][indexVal]=model;return}for(attribute in this._indexes){indexVal=model.hasOwnProperty(attribute)?model[attribute]:model.get&&model.get(attribute);if(indexVal!=null)this._indexes[attribute][indexVal]=model}},_isDerivedIndex:function(proto){if(!proto||typeof proto._derived!=="object"){return false}return Object.keys(proto._derived).indexOf(this.mainIndex)>=0},_addReference:function(model,options){this._index(model);if(!model.collection)model.collection=this;if(model.on)model.on("all",this._onModelEvent,this)},_removeReference:function(model,options){if(this===model.collection)delete model.collection;this._deIndex(model);if(model.off)model.off("all",this._onModelEvent,this)},_onModelEvent:function(event,model,collection,options){var eventName=event.split(":")[0];var attribute=event.split(":")[1];if((eventName==="add"||eventName==="remove")&&collection!==this)return;if(eventName==="destroy")this.remove(model,options);if(model&&eventName==="change"&&attribute&&this._indexes[attribute]){this._deIndex(model,attribute,model.previousAttributes()[attribute]);this._index(model,attribute)}this.trigger.apply(this,arguments)}});Object.defineProperties(Collection.prototype,{length:{get:function(){return this.models.length}},isCollection:{value:true}});var arrayMethods=["indexOf","lastIndexOf","every","some","forEach","map","filter","reduce","reduceRight"];arrayMethods.forEach(function(method){Collection.prototype[method]=function(){return this.models[method].apply(this.models,arguments)}});Collection.prototype.each=Collection.prototype.forEach;Collection.extend=classExtend;module.exports=Collection},{"ampersand-class-extend":1,"ampersand-events":2,"lodash.assign":17,"lodash.bind":27,"lodash.isarray":31}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){if(typeof window!=="undefined"){window.ampersand=window.ampersand||{};window.ampersand["ampersand-events"]=window.ampersand["ampersand-events"]||[];window.ampersand["ampersand-events"].push("1.1.1")}var runOnce=require("lodash.once");var uniqueId=require("lodash.uniqueid");var keys=require("lodash.keys");var isEmpty=require("lodash.isempty");var each=require("lodash.foreach");var bind=require("lodash.bind");var assign=require("lodash.assign");var slice=Array.prototype.slice;var eventSplitter=/\s+/;var Events={on:function(name,callback,context){if(!eventsApi(this,"on",name,[callback,context])||!callback)return this;this._events||(this._events={});var events=this._events[name]||(this._events[name]=[]);events.push({callback:callback,context:context,ctx:context||this});return this},once:function(name,callback,context){if(!eventsApi(this,"once",name,[callback,context])||!callback)return this;var self=this;var once=runOnce(function(){self.off(name,once);callback.apply(this,arguments)});once._callback=callback;return this.on(name,once,context)},off:function(name,callback,context){var retain,ev,events,names,i,l,j,k;if(!this._events||!eventsApi(this,"off",name,[callback,context]))return this;if(!name&&!callback&&!context){this._events=void 0;return this}names=name?[name]:keys(this._events);for(i=0,l=names.length;i<l;i++){name=names[i];if(events=this._events[name]){this._events[name]=retain=[];if(callback||context){for(j=0,k=events.length;j<k;j++){ev=events[j];if(callback&&callback!==ev.callback&&callback!==ev.callback._callback||context&&context!==ev.context){retain.push(ev)}}}if(!retain.length)delete this._events[name]}}return this},trigger:function(name){if(!this._events)return this;var args=slice.call(arguments,1);if(!eventsApi(this,"trigger",name,args))return this;var events=this._events[name];var allEvents=this._events.all;if(events)triggerEvents(events,args);if(allEvents)triggerEvents(allEvents,arguments);return this},stopListening:function(obj,name,callback){var listeningTo=this._listeningTo;if(!listeningTo)return this;var remove=!name&&!callback;if(!callback&&typeof name==="object")callback=this;if(obj)(listeningTo={})[obj._listenId]=obj;for(var id in listeningTo){obj=listeningTo[id];obj.off(name,callback,this);if(remove||isEmpty(obj._events))delete this._listeningTo[id]}return this},createEmitter:function(obj){return assign(obj||{},Events)}};Events.bind=Events.on;Events.unbind=Events.off;var eventsApi=function(obj,action,name,rest){if(!name)return true;if(typeof name==="object"){for(var key in name){obj[action].apply(obj,[key,name[key]].concat(rest))}return false}if(eventSplitter.test(name)){var names=name.split(eventSplitter);for(var i=0,l=names.length;i<l;i++){obj[action].apply(obj,[names[i]].concat(rest))}return false}return true};var triggerEvents=function(events,args){var ev;var i=-1;var l=events.length;var a1=args[0];var a2=args[1];var a3=args[2];switch(args.length){case 0:while(++i<l)(ev=events[i]).callback.call(ev.ctx);return;case 1:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1);return;case 2:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2);return;case 3:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2,a3);return;default:while(++i<l)(ev=events[i]).callback.apply(ev.ctx,args);return}};var listenMethods={listenTo:"on",listenToOnce:"once"};each(listenMethods,function(implementation,method){Events[method]=function(obj,name,callback,run){var listeningTo=this._listeningTo||(this._listeningTo={});var id=obj._listenId||(obj._listenId=uniqueId("l"));listeningTo[id]=obj;if(!callback&&typeof name==="object")callback=this;obj[implementation](name,callback,this);return this}});Events.listenToAndRun=function(obj,name,callback){Events.listenTo.apply(this,arguments);if(!callback&&typeof name==="object")callback=this;callback.apply(this);return this};module.exports=Events},{"lodash.assign":15,"lodash.bind":25,"lodash.foreach":2,"lodash.isempty":6,"lodash.keys":8,"lodash.once":11,"lodash.uniqueid":89}],2:[function(require,module,exports){var arrayEach=require("lodash._arrayeach"),baseEach=require("lodash._baseeach"),bindCallback=require("lodash._bindcallback"),isArray=require("lodash.isarray");function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return typeof iteratee=="function"&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}var forEach=createForEach(arrayEach,baseEach);module.exports=forEach},{"lodash._arrayeach":3,"lodash._baseeach":4,"lodash._bindcallback":5,"lodash.isarray":48}],3:[function(require,module,exports){function arrayEach(array,iteratee){var index=-1,length=array.length;while(++index<length){if(iteratee(array[index],index,array)===false){break}}return array}module.exports=arrayEach},{}],4:[function(require,module,exports){var keys=require("lodash.keys");var MAX_SAFE_INTEGER=9007199254740991;var baseEach=createBaseEach(baseForOwn);var baseFor=createBaseFor();function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseProperty(key){return function(object){return object==null?undefined:object[key]}}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length)){return eachFunc(collection,iteratee)}var index=fromRight?length:-1,iterable=toObject(collection);while(fromRight?index--:++index<length){if(iteratee(iterable[index],index,iterable)===false){break}}return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;while(fromRight?index--:++index<length){var key=props[index];if(iteratee(iterable[key],key,iterable)===false){break}}return object}}var getLength=baseProperty("length");function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseEach},{"lodash.keys":8}],5:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(thisArg===undefined){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],6:[function(require,module,exports){var isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray"),isFunction=require("lodash.isfunction"),isString=require("lodash.isstring"),keys=require("lodash.keys");function isObjectLike(value){return!!value&&typeof value=="object"}var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isEmpty(value){if(value==null){return true}if(isArrayLike(value)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))){return!value.length}return!keys(value).length}module.exports=isEmpty},{"lodash.isarguments":7,"lodash.isarray":48,"lodash.isfunction":57,"lodash.isstring":59,"lodash.keys":8}],7:[function(require,module,exports){(function(global){var MAX_SAFE_INTEGER=9007199254740991;var argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]";var objectProto=global.Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objectToString=objectProto.toString;var propertyIsEnumerable=objectProto.propertyIsEnumerable;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArguments(value){return isArrayLikeObject(value)&&hasOwnProperty.call(value,"callee")&&(!propertyIsEnumerable.call(value,"callee")||objectToString.call(value)==argsTag)}function isArrayLike(value){return value!=null&&!(typeof value=="function"&&isFunction(value))&&isLength(getLength(value))}function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isObjectLike(value){return!!value&&typeof value=="object"}module.exports=isArguments}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],8:[function(require,module,exports){var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var nativeKeys=getNative(Object,"keys");var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||typeof object!="function"&&isArrayLike(object)){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keys},{"lodash._getnative":9,"lodash.isarguments":10,"lodash.isarray":48}],9:[function(require,module,exports){var funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=getNative},{}],10:[function(require,module,exports){module.exports=require(7)},{}],11:[function(require,module,exports){var before=require("lodash.before");function once(func){return before(2,func)}module.exports=once},{"lodash.before":12}],12:[function(require,module,exports){var FUNC_ERROR_TEXT="Expected a function";function before(n,func){var result;if(typeof func!="function"){if(typeof n=="function"){var temp=n;n=func;func=temp}else{throw new TypeError(FUNC_ERROR_TEXT)}}return function(){if(--n>0){result=func.apply(this,arguments)}if(n<=1){func=undefined}return result}}module.exports=before},{}],13:[function(require,module,exports){module.exports=function arrayNext(array,currentItem){var len=array.length;var newIndex=array.indexOf(currentItem)+1;if(newIndex>len-1)newIndex=0;return array[newIndex]}},{}],14:[function(require,module,exports){var slice=Array.prototype.slice;function KeyTreeStore(options){options=options||{};if(typeof options!=="object"){throw new TypeError("Options must be an object")}var DEFAULT_SEPARATOR=".";this.storage={};this.separator=options.separator||DEFAULT_SEPARATOR}KeyTreeStore.prototype.add=function(keypath,obj){var arr=this.storage[keypath]||(this.storage[keypath]=[]);arr.push(obj)};KeyTreeStore.prototype.remove=function(obj){var path,arr;for(path in this.storage){arr=this.storage[path];arr.some(function(item,index){if(item===obj){arr.splice(index,1);return true}})}};KeyTreeStore.prototype.get=function(keypath){var res=[];var key;for(key in this.storage){if(!keypath||keypath===key||key.indexOf(keypath+this.separator)===0){res=res.concat(this.storage[key])}}return res};KeyTreeStore.prototype.getGrouped=function(keypath){var res={};var key;for(key in this.storage){if(!keypath||keypath===key||key.indexOf(keypath+this.separator)===0){res[key]=slice.call(this.storage[key])}}return res};KeyTreeStore.prototype.getAll=function(keypath){var res={};var key;for(key in this.storage){if(keypath===key||key.indexOf(keypath+this.separator)===0){res[key]=slice.call(this.storage[key])}}return res};KeyTreeStore.prototype.run=function(keypath,context){var args=slice.call(arguments,2);this.get(keypath).forEach(function(fn){fn.apply(context||this,args)})};module.exports=KeyTreeStore},{}],15:[function(require,module,exports){var baseAssign=require("lodash._baseassign"),createAssigner=require("lodash._createassigner"),keys=require("lodash.keys");function assignWith(object,source,customizer){var index=-1,props=keys(source),length=props.length;while(++index<length){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);if((result===result?result!==value:value===value)||value===undefined&&!(key in object)){object[key]=result}}return object}var assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)});module.exports=assign},{"lodash._baseassign":16,"lodash._createassigner":18,"lodash.keys":22}],16:[function(require,module,exports){var baseCopy=require("lodash._basecopy"),keys=require("lodash.keys");function baseAssign(object,source){return source==null?object:baseCopy(source,keys(source),object)}module.exports=baseAssign},{"lodash._basecopy":17,"lodash.keys":22}],17:[function(require,module,exports){function baseCopy(source,props,object){object||(object={});var index=-1,length=props.length;while(++index<length){var key=props[index];object[key]=source[key]}return object}module.exports=baseCopy},{}],18:[function(require,module,exports){var bindCallback=require("lodash._bindcallback"),isIterateeCall=require("lodash._isiterateecall"),restParam=require("lodash.restparam");function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=object==null?0:sources.length,customizer=length>2?sources[length-2]:undefined,guard=length>2?sources[2]:undefined,thisArg=length>1?sources[length-1]:undefined;if(typeof customizer=="function"){customizer=bindCallback(customizer,thisArg,5);length-=2}else{customizer=typeof thisArg=="function"?thisArg:undefined;length-=customizer?1:0}if(guard&&isIterateeCall(sources[0],sources[1],guard)){customizer=length<3?undefined:customizer;length=1}while(++index<length){var source=sources[index];if(source){assigner(object,source,customizer)}}return object})}module.exports=createAssigner},{"lodash._bindcallback":19,"lodash._isiterateecall":20,"lodash.restparam":21}],19:[function(require,module,exports){module.exports=require(5)},{}],20:[function(require,module,exports){var reIsUint=/^\d+$/;var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isIterateeCall(value,index,object){if(!isObject(object)){return false}var type=typeof index;if(type=="number"?isArrayLike(object)&&isIndex(index,object.length):type=="string"&&index in object){var other=object[index];return value===value?value===other:other!==other}return false}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isIterateeCall},{}],21:[function(require,module,exports){var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max;function restParam(func,start){if(typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}start=nativeMax(start===undefined?func.length-1:+start||0,0);return function(){var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);while(++index<length){rest[index]=args[start+index]}switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);index=-1;while(++index<start){otherArgs[index]=args[index]}otherArgs[start]=rest;return func.apply(this,otherArgs)}}module.exports=restParam},{}],22:[function(require,module,exports){module.exports=require(8)},{"lodash._getnative":23,"lodash.isarguments":24,"lodash.isarray":48}],23:[function(require,module,exports){module.exports=require(9)},{}],24:[function(require,module,exports){module.exports=require(7)},{}],25:[function(require,module,exports){var createWrapper=require("lodash._createwrapper"),replaceHolders=require("lodash._replaceholders"),restParam=require("lodash.restparam");var BIND_FLAG=1,PARTIAL_FLAG=32;var bind=restParam(function(func,thisArg,partials){var bitmask=BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,bind.placeholder);bitmask|=PARTIAL_FLAG}return createWrapper(func,bitmask,thisArg,partials,holders)});bind.placeholder={};module.exports=bind},{"lodash._createwrapper":26,"lodash._replaceholders":27,"lodash.restparam":28}],26:[function(require,module,exports){(function(global){var BIND_FLAG=1,BIND_KEY_FLAG=2,CURRY_BOUND_FLAG=4,CURRY_FLAG=8,CURRY_RIGHT_FLAG=16,PARTIAL_FLAG=32,PARTIAL_RIGHT_FLAG=64,ARY_FLAG=128,FLIP_FLAG=512;var FUNC_ERROR_TEXT="Expected a function";var INFINITY=1/0,MAX_SAFE_INTEGER=9007199254740991,MAX_INTEGER=1.7976931348623157e308,NAN=0/0;var PLACEHOLDER="__lodash_placeholder__";var funcTag="[object Function]",genTag="[object GeneratorFunction]";var reTrim=/^\s+|\s+$/g;var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;var reIsBinary=/^0b[01]+$/i;var reIsOctal=/^0o[0-7]+$/i;var reIsUint=/^(?:0|[1-9]\d*)$/;var freeParseInt=parseInt;function apply(func,thisArg,args){var length=args?args.length:0;switch(length){case 0:return func.call(thisArg);case 1:return func.call(thisArg,args[0]);case 2:return func.call(thisArg,args[0],args[1]);case 3:return func.call(thisArg,args[0],args[1],args[2])}return func.apply(thisArg,args)}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){if(array[index]===placeholder){array[index]=PLACEHOLDER;result[++resIndex]=index}}return result}var objectProto=global.Object.prototype;var objectToString=objectProto.toString;var nativeMax=Math.max,nativeMin=Math.min;var baseCreate=function(){function object(){}return function(prototype){if(isObject(prototype)){object.prototype=prototype;var result=new object;object.prototype=undefined}return result||{}}}();function composeArgs(args,partials,holders){var holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),leftIndex=-1,leftLength=partials.length,result=Array(leftLength+argsLength);while(++leftIndex<leftLength){result[leftIndex]=partials[leftIndex]}while(++argsIndex<holdersLength){result[holders[argsIndex]]=args[argsIndex]}while(argsLength--){result[leftIndex++]=args[argsIndex++]}return result}function composeArgsRight(args,partials,holders){var holdersIndex=-1,holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),rightIndex=-1,rightLength=partials.length,result=Array(argsLength+rightLength);while(++argsIndex<argsLength){result[argsIndex]=args[argsIndex]}var offset=argsIndex;while(++rightIndex<rightLength){result[offset+rightIndex]=partials[rightIndex]}while(++holdersIndex<holdersLength){result[offset+holders[holdersIndex]]=args[argsIndex++]}return result}function copyArray(source,array){var index=-1,length=source.length;array||(array=Array(length));while(++index<length){array[index]=source[index]}return array}function createBaseWrapper(func,bitmask,thisArg){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var fn=this&&this!==global&&this instanceof wrapper?Ctor:func;return fn.apply(isBind?thisArg:this,arguments)}return wrapper}function createCtorWrapper(Ctor){return function(){var args=arguments;switch(args.length){case 0:return new Ctor;case 1:return new Ctor(args[0]);case 2:return new Ctor(args[0],args[1]);case 3:return new Ctor(args[0],args[1],args[2]);case 4:return new Ctor(args[0],args[1],args[2],args[3]);case 5:return new Ctor(args[0],args[1],args[2],args[3],args[4]);case 6:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5]);case 7:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5],args[6])}var thisBinding=baseCreate(Ctor.prototype),result=Ctor.apply(thisBinding,args);return isObject(result)?result:thisBinding}}function createCurryWrapper(func,bitmask,arity){var Ctor=createCtorWrapper(func);function wrapper(){var length=arguments.length,index=length,args=Array(length),fn=this&&this!==global&&this instanceof wrapper?Ctor:func,placeholder=wrapper.placeholder;
while(index--){args[index]=arguments[index]}var holders=length<3&&args[0]!==placeholder&&args[length-1]!==placeholder?[]:replaceHolders(args,placeholder);length-=holders.length;return length<arity?createRecurryWrapper(func,bitmask,createHybridWrapper,placeholder,undefined,args,holders,undefined,undefined,arity-length):apply(fn,this,args)}return wrapper}function createHybridWrapper(func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity){var isAry=bitmask&ARY_FLAG,isBind=bitmask&BIND_FLAG,isBindKey=bitmask&BIND_KEY_FLAG,isCurry=bitmask&CURRY_FLAG,isCurryRight=bitmask&CURRY_RIGHT_FLAG,isFlip=bitmask&FLIP_FLAG,Ctor=isBindKey?undefined:createCtorWrapper(func);function wrapper(){var length=arguments.length,index=length,args=Array(length);while(index--){args[index]=arguments[index]}if(partials){args=composeArgs(args,partials,holders)}if(partialsRight){args=composeArgsRight(args,partialsRight,holdersRight)}if(isCurry||isCurryRight){var placeholder=wrapper.placeholder,argsHolders=replaceHolders(args,placeholder);length-=argsHolders.length;if(length<arity){return createRecurryWrapper(func,bitmask,createHybridWrapper,placeholder,thisArg,args,argsHolders,argPos,ary,arity-length)}}var thisBinding=isBind?thisArg:this,fn=isBindKey?thisBinding[func]:func;if(argPos){args=reorder(args,argPos)}else if(isFlip&&args.length>1){args.reverse()}if(isAry&&ary<args.length){args.length=ary}if(this&&this!==global&&this instanceof wrapper){fn=Ctor||createCtorWrapper(fn)}return fn.apply(thisBinding,args)}return wrapper}function createPartialWrapper(func,bitmask,thisArg,partials){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength),fn=this&&this!==global&&this instanceof wrapper?Ctor:func;while(++leftIndex<leftLength){args[leftIndex]=partials[leftIndex]}while(argsLength--){args[leftIndex++]=arguments[++argsIndex]}return apply(fn,isBind?thisArg:this,args)}return wrapper}function createRecurryWrapper(func,bitmask,wrapFunc,placeholder,thisArg,partials,holders,argPos,ary,arity){var isCurry=bitmask&CURRY_FLAG,newArgPos=argPos?copyArray(argPos):undefined,newsHolders=isCurry?holders:undefined,newHoldersRight=isCurry?undefined:holders,newPartials=isCurry?partials:undefined,newPartialsRight=isCurry?undefined:partials;bitmask|=isCurry?PARTIAL_FLAG:PARTIAL_RIGHT_FLAG;bitmask&=~(isCurry?PARTIAL_RIGHT_FLAG:PARTIAL_FLAG);if(!(bitmask&CURRY_BOUND_FLAG)){bitmask&=~(BIND_FLAG|BIND_KEY_FLAG)}var result=wrapFunc(func,bitmask,thisArg,newPartials,newsHolders,newPartialsRight,newHoldersRight,newArgPos,ary,arity);result.placeholder=placeholder;return result}function createWrapper(func,bitmask,thisArg,partials,holders,argPos,ary,arity){var isBindKey=bitmask&BIND_KEY_FLAG;if(!isBindKey&&typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}var length=partials?partials.length:0;if(!length){bitmask&=~(PARTIAL_FLAG|PARTIAL_RIGHT_FLAG);partials=holders=undefined}ary=ary===undefined?ary:nativeMax(toInteger(ary),0);arity=arity===undefined?arity:toInteger(arity);length-=holders?holders.length:0;if(bitmask&PARTIAL_RIGHT_FLAG){var partialsRight=partials,holdersRight=holders;partials=holders=undefined}var newData=[func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity];func=newData[0];bitmask=newData[1];thisArg=newData[2];partials=newData[3];holders=newData[4];arity=newData[9]=newData[9]==null?isBindKey?0:func.length:nativeMax(newData[9]-length,0);if(!arity&&bitmask&(CURRY_FLAG|CURRY_RIGHT_FLAG)){bitmask&=~(CURRY_FLAG|CURRY_RIGHT_FLAG)}if(!bitmask||bitmask==BIND_FLAG){var result=createBaseWrapper(func,bitmask,thisArg)}else if(bitmask==CURRY_FLAG||bitmask==CURRY_RIGHT_FLAG){result=createCurryWrapper(func,bitmask,arity)}else if((bitmask==PARTIAL_FLAG||bitmask==(BIND_FLAG|PARTIAL_FLAG))&&!holders.length){result=createPartialWrapper(func,bitmask,thisArg,partials)}else{result=createHybridWrapper.apply(undefined,newData)}return result}function reorder(array,indexes){var arrLength=array.length,length=nativeMin(indexes.length,arrLength),oldArray=copyArray(array);while(length--){var index=indexes[length];array[length]=isIndex(index,arrLength)?oldArray[index]:undefined}return array}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function toInteger(value){if(!value){return value===0?value:0}value=toNumber(value);if(value===INFINITY||value===-INFINITY){var sign=value<0?-1:1;return sign*MAX_INTEGER}var remainder=value%1;return value===value?remainder?value-remainder:value:0}function toNumber(value){if(isObject(value)){var other=isFunction(value.valueOf)?value.valueOf():value;value=isObject(other)?other+"":other}if(typeof value!="string"){return value===0?value:+value}value=value.replace(reTrim,"");var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}module.exports=createWrapper}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],27:[function(require,module,exports){var PLACEHOLDER="__lodash_placeholder__";function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){if(array[index]===placeholder){array[index]=PLACEHOLDER;result[++resIndex]=index}}return result}module.exports=replaceHolders},{}],28:[function(require,module,exports){module.exports=require(21)},{}],29:[function(require,module,exports){(function(global){var INFINITY=1/0;var symbolTag="[object Symbol]";var reUnescapedHtml=/[&<>"'`]/g,reHasUnescapedHtml=RegExp(reUnescapedHtml.source);var htmlEscapes={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"};function escapeHtmlChar(chr){return htmlEscapes[chr]}var objectProto=global.Object.prototype;var objectToString=objectProto.toString;var _Symbol=global.Symbol;var symbolProto=_Symbol?_Symbol.prototype:undefined,symbolToString=_Symbol?symbolProto.toString:undefined;function isObjectLike(value){return!!value&&typeof value=="object"}function isSymbol(value){return typeof value=="symbol"||isObjectLike(value)&&objectToString.call(value)==symbolTag}function toString(value){if(typeof value=="string"){return value}if(value==null){return""}if(isSymbol(value)){return _Symbol?symbolToString.call(value):""}var result=value+"";return result=="0"&&1/value==-INFINITY?"-0":result}function escape(string){string=toString(string);return string&&reHasUnescapedHtml.test(string)?string.replace(reUnescapedHtml,escapeHtmlChar):string}module.exports=escape}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],30:[function(require,module,exports){var baseFor=require("lodash._basefor"),bindCallback=require("lodash._bindcallback"),keys=require("lodash.keys");function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function createForOwn(objectFunc){return function(object,iteratee,thisArg){if(typeof iteratee!="function"||thisArg!==undefined){iteratee=bindCallback(iteratee,thisArg,3)}return objectFunc(object,iteratee)}}var forOwn=createForOwn(baseForOwn);module.exports=forOwn},{"lodash._basefor":31,"lodash._bindcallback":32,"lodash.keys":33}],31:[function(require,module,exports){var baseFor=createBaseFor();function createBaseFor(fromRight){return function(object,iteratee,keysFunc){var index=-1,iterable=Object(object),props=keysFunc(object),length=props.length;while(length--){var key=props[fromRight?length:++index];if(iteratee(iterable[key],key,iterable)===false){break}}return object}}module.exports=baseFor},{}],32:[function(require,module,exports){module.exports=require(5)},{}],33:[function(require,module,exports){module.exports=require(8)},{"lodash._getnative":34,"lodash.isarguments":35,"lodash.isarray":48}],34:[function(require,module,exports){module.exports=require(9)},{}],35:[function(require,module,exports){module.exports=require(7)},{}],36:[function(require,module,exports){var baseGet=require("lodash._baseget"),baseSlice=require("lodash._baseslice"),toPath=require("lodash._topath"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var MAX_SAFE_INTEGER=9007199254740991;function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isKey(value,object){var type=typeof value;if(type=="string"&&reIsPlainProp.test(value)||type=="number"){return true}if(isArray(value)){return false}var result=!reIsDeepProp.test(value);return result||object!=null&&value in toObject(object)}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function toObject(value){return isObject(value)?value:Object(value)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function has(object,path){if(object==null){return false}var result=hasOwnProperty.call(object,path);if(!result&&!isKey(path)){path=toPath(path);object=path.length==1?object:baseGet(object,baseSlice(path,0,-1));if(object==null){return false}path=last(path);result=hasOwnProperty.call(object,path)}return result||isLength(object.length)&&isIndex(path,object.length)&&(isArray(object)||isArguments(object))}module.exports=has},{"lodash._baseget":37,"lodash._baseslice":38,"lodash._topath":39,"lodash.isarguments":40,"lodash.isarray":48}],37:[function(require,module,exports){function baseGet(object,path,pathKey){if(object==null){return}if(pathKey!==undefined&&pathKey in toObject(object)){path=[pathKey]}var index=0,length=path.length;while(object!=null&&index<length){object=object[path[index++]]}return index&&index==length?object:undefined}function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseGet},{}],38:[function(require,module,exports){function baseSlice(array,start,end){var index=-1,length=array.length;start=start==null?0:+start||0;if(start<0){start=-start>length?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index<length){result[index]=array[index+start]}return result}module.exports=baseSlice},{}],39:[function(require,module,exports){var isArray=require("lodash.isarray");var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;var reEscapeChar=/\\(\\)?/g;function baseToString(value){return value==null?"":value+""}function toPath(value){if(isArray(value)){return value}var result=[];baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,"$1"):number||match)});return result}module.exports=toPath},{"lodash.isarray":48}],40:[function(require,module,exports){module.exports=require(7)},{}],41:[function(require,module,exports){var baseIndexOf=require("lodash._baseindexof"),baseValues=require("lodash._basevalues"),isIterateeCall=require("lodash._isiterateecall"),isArray=require("lodash.isarray"),isString=require("lodash.isstring"),keys=require("lodash.keys");var nativeMax=Math.max;var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;if(!isLength(length)){collection=values(collection);length=collection.length}if(typeof fromIndex!="number"||guard&&isIterateeCall(target,fromIndex,guard)){fromIndex=0}else{fromIndex=fromIndex<0?nativeMax(length+fromIndex,0):fromIndex||0}return typeof collection=="string"||!isArray(collection)&&isString(collection)?fromIndex<=length&&collection.indexOf(target,fromIndex)>-1:!!length&&baseIndexOf(collection,target,fromIndex)>-1}function values(object){return baseValues(object,keys(object))}module.exports=includes},{"lodash._baseindexof":42,"lodash._basevalues":43,"lodash._isiterateecall":44,"lodash.isarray":48,"lodash.isstring":59,"lodash.keys":45}],42:[function(require,module,exports){function baseIndexOf(array,value,fromIndex){if(value!==value){return indexOfNaN(array,fromIndex)}var index=fromIndex-1,length=array.length;while(++index<length){if(array[index]===value){return index}}return-1}function indexOfNaN(array,fromIndex,fromRight){var length=array.length,index=fromIndex+(fromRight?0:-1);while(fromRight?index--:++index<length){var other=array[index];if(other!==other){return index}}return-1}module.exports=baseIndexOf},{}],43:[function(require,module,exports){function baseValues(object,props){var index=-1,length=props.length,result=Array(length);while(++index<length){result[index]=object[props[index]]}return result}module.exports=baseValues},{}],44:[function(require,module,exports){module.exports=require(20)},{}],45:[function(require,module,exports){module.exports=require(8)},{"lodash._getnative":46,"lodash.isarguments":47,"lodash.isarray":48}],46:[function(require,module,exports){module.exports=require(9)},{}],47:[function(require,module,exports){module.exports=require(7)},{}],48:[function(require,module,exports){var arrayTag="[object Array]",funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var nativeIsArray=getNative(Array,"isArray");var MAX_SAFE_INTEGER=9007199254740991;function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=isArray},{}],49:[function(require,module,exports){(function(global){var dateTag="[object Date]";var objectProto=global.Object.prototype;var objectToString=objectProto.toString;function isDate(value){return isObjectLike(value)&&objectToString.call(value)==dateTag}function isObjectLike(value){return!!value&&typeof value=="object"}module.exports=isDate}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],50:[function(require,module,exports){var baseIsEqual=require("lodash._baseisequal"),bindCallback=require("lodash._bindcallback");function isEqual(value,other,customizer,thisArg){customizer=typeof customizer=="function"?bindCallback(customizer,thisArg,3):undefined;var result=customizer?customizer(value,other):undefined;return result===undefined?baseIsEqual(value,other,customizer):!!result}module.exports=isEqual},{"lodash._baseisequal":51,"lodash._bindcallback":56}],51:[function(require,module,exports){var isArray=require("lodash.isarray"),isTypedArray=require("lodash.istypedarray"),keys=require("lodash.keys");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",stringTag="[object String]";function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function arraySome(array,predicate){var index=-1,length=array.length;while(++index<length){if(predicate(array[index],index,array)){return true}}return false}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other){return true}if(value==null||other==null||!isObject(value)&&!isObjectLike(other)){return value!==value&&other!==other}return baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;if(!objIsArr){objTag=objToString.call(object);if(objTag==argsTag){objTag=objectTag}else if(objTag!=objectTag){objIsArr=isTypedArray(object)}}if(!othIsArr){othTag=objToString.call(other);if(othTag==argsTag){othTag=objectTag}else if(othTag!=objectTag){othIsArr=isTypedArray(other)}}var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!(objIsArr||objIsObj)){return equalByTag(object,other,objTag)}if(!isLoose){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,"__wrapped__"),othIsWrapped=othIsObj&&hasOwnProperty.call(other,"__wrapped__");if(objIsWrapped||othIsWrapped){return equalFunc(objIsWrapped?object.value():object,othIsWrapped?other.value():other,customizer,isLoose,stackA,stackB)}}if(!isSameTag){return false}stackA||(stackA=[]);stackB||(stackB=[]);var length=stackA.length;while(length--){if(stackA[length]==object){return stackB[length]==other}}stackA.push(object);stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);stackA.pop();stackB.pop();return result}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength)){return false}while(++index<arrLength){var arrValue=array[index],othValue=other[index],result=customizer?customizer(isLoose?othValue:arrValue,isLoose?arrValue:othValue,index):undefined;if(result!==undefined){if(result){continue}return false}if(isLoose){if(!arraySome(other,function(othValue){return arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)})){return false}}else if(!(arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))){return false}}return true}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:object==+other;case regexpTag:case stringTag:return object==other+""}return false}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose){return false}var index=objLength;while(index--){var key=objProps[index];if(!(isLoose?key in other:hasOwnProperty.call(other,key))){return false}}var skipCtor=isLoose;while(++index<objLength){key=objProps[index];var objValue=object[key],othValue=other[key],result=customizer?customizer(isLoose?othValue:objValue,isLoose?objValue:othValue,key):undefined;if(!(result===undefined?equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB):result)){return false}skipCtor||(skipCtor=key=="constructor")}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&("constructor"in object&&"constructor"in other)&&!(typeof objCtor=="function"&&objCtor instanceof objCtor&&typeof othCtor=="function"&&othCtor instanceof othCtor)){return false}}return true}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseIsEqual},{"lodash.isarray":48,"lodash.istypedarray":52,"lodash.keys":53}],52:[function(require,module,exports){(function(global){var MAX_SAFE_INTEGER=9007199254740991;var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;var objectProto=global.Object.prototype;var objectToString=objectProto.toString;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObjectLike(value){return!!value&&typeof value=="object"}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objectToString.call(value)]}module.exports=isTypedArray}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],53:[function(require,module,exports){module.exports=require(8)},{"lodash._getnative":54,"lodash.isarguments":55,"lodash.isarray":48}],54:[function(require,module,exports){module.exports=require(9)},{}],55:[function(require,module,exports){module.exports=require(7)},{}],56:[function(require,module,exports){module.exports=require(5)},{}],57:[function(require,module,exports){(function(global){var funcTag="[object Function]",genTag="[object GeneratorFunction]";var objectProto=global.Object.prototype;var objectToString=objectProto.toString;function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isFunction}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],58:[function(require,module,exports){function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isObject},{}],59:[function(require,module,exports){var stringTag="[object String]";function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var objToString=objectProto.toString;function isString(value){return typeof value=="string"||isObjectLike(value)&&objToString.call(value)==stringTag}module.exports=isString},{}],60:[function(require,module,exports){var arrayMap=require("lodash._arraymap"),baseDifference=require("lodash._basedifference"),baseFlatten=require("lodash._baseflatten"),bindCallback=require("lodash._bindcallback"),pickByArray=require("lodash._pickbyarray"),pickByCallback=require("lodash._pickbycallback"),keysIn=require("lodash.keysin"),restParam=require("lodash.restparam");var omit=restParam(function(object,props){if(object==null){return{}}if(typeof props[0]!="function"){var props=arrayMap(baseFlatten(props),String);return pickByArray(object,baseDifference(keysIn(object),props))}var predicate=bindCallback(props[0],props[1],3);return pickByCallback(object,function(value,key,object){return!predicate(value,key,object)})});module.exports=omit},{"lodash._arraymap":61,"lodash._basedifference":62,"lodash._baseflatten":67,"lodash._bindcallback":69,"lodash._pickbyarray":70,"lodash._pickbycallback":71,"lodash.keysin":73,"lodash.restparam":75}],61:[function(require,module,exports){function arrayMap(array,iteratee){var index=-1,length=array.length,result=Array(length);while(++index<length){result[index]=iteratee(array[index],index,array)}return result}module.exports=arrayMap},{}],62:[function(require,module,exports){var baseIndexOf=require("lodash._baseindexof"),cacheIndexOf=require("lodash._cacheindexof"),createCache=require("lodash._createcache");var LARGE_ARRAY_SIZE=200;function baseDifference(array,values){var length=array?array.length:0,result=[];if(!length){return result}var index=-1,indexOf=baseIndexOf,isCommon=true,cache=isCommon&&values.length>=LARGE_ARRAY_SIZE?createCache(values):null,valuesLength=values.length;if(cache){indexOf=cacheIndexOf;isCommon=false;values=cache}outer:while(++index<length){var value=array[index];if(isCommon&&value===value){var valuesIndex=valuesLength;while(valuesIndex--){if(values[valuesIndex]===value){continue outer}}result.push(value)}else if(indexOf(values,value,0)<0){result.push(value)}}return result}module.exports=baseDifference},{"lodash._baseindexof":63,"lodash._cacheindexof":64,"lodash._createcache":65}],63:[function(require,module,exports){module.exports=require(42)},{}],64:[function(require,module,exports){function cacheIndexOf(cache,value){var data=cache.data,result=typeof value=="string"||isObject(value)?data.set.has(value):data.hash[value];return result?0:-1}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=cacheIndexOf},{}],65:[function(require,module,exports){(function(global){var getNative=require("lodash._getnative");var Set=getNative(global,"Set");var nativeCreate=getNative(Object,"create");function SetCache(values){var length=values?values.length:0;this.data={hash:nativeCreate(null),set:new Set};while(length--){this.push(values[length])}}function cachePush(value){var data=this.data;if(typeof value=="string"||isObject(value)){data.set.add(value)}else{data.hash[value]=true}}function createCache(values){return nativeCreate&&Set?new SetCache(values):null}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}SetCache.prototype.push=cachePush;module.exports=createCache}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"lodash._getnative":66}],66:[function(require,module,exports){module.exports=require(9)},{}],67:[function(require,module,exports){var isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");function isObjectLike(value){return!!value&&typeof value=="object"}var MAX_SAFE_INTEGER=9007199254740991;function arrayPush(array,values){var index=-1,length=values.length,offset=array.length;while(++index<length){array[offset+index]=values[index]}return array}function baseFlatten(array,isDeep,isStrict,result){result||(result=[]);var index=-1,length=array.length;while(++index<length){var value=array[index];if(isObjectLike(value)&&isArrayLike(value)&&(isStrict||isArray(value)||isArguments(value))){if(isDeep){baseFlatten(value,isDeep,isStrict,result)}else{arrayPush(result,value)}}else if(!isStrict){result[result.length]=value}}return result}function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}module.exports=baseFlatten},{"lodash.isarguments":68,"lodash.isarray":48}],68:[function(require,module,exports){module.exports=require(7)},{}],69:[function(require,module,exports){module.exports=require(5)},{}],70:[function(require,module,exports){function pickByArray(object,props){object=toObject(object);var index=-1,length=props.length,result={};while(++index<length){var key=props[index];if(key in object){result[key]=object[key]}}return result}function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=pickByArray},{}],71:[function(require,module,exports){var baseFor=require("lodash._basefor"),keysIn=require("lodash.keysin");function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}function pickByCallback(object,predicate){var result={};baseForIn(object,function(value,key,object){if(predicate(value,key,object)){result[key]=value}});return result}module.exports=pickByCallback},{"lodash._basefor":72,"lodash.keysin":73}],72:[function(require,module,exports){module.exports=require(31)},{}],73:[function(require,module,exports){var isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var MAX_SAFE_INTEGER=9007199254740991;function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keysIn},{"lodash.isarguments":74,"lodash.isarray":48}],74:[function(require,module,exports){module.exports=require(7)},{}],75:[function(require,module,exports){module.exports=require(21)},{}],76:[function(require,module,exports){var baseGet=require("lodash._baseget"),baseSlice=require("lodash._baseslice"),toPath=require("lodash._topath"),isArray=require("lodash.isarray"),isFunction=require("lodash.isfunction");var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey(value,object){var type=typeof value;if(type=="string"&&reIsPlainProp.test(value)||type=="number"){return true}if(isArray(value)){return false}var result=!reIsDeepProp.test(value);return result||object!=null&&value in toObject(object)}function toObject(value){return isObject(value)?value:Object(value)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function result(object,path,defaultValue){var result=object==null?undefined:object[path];if(result===undefined){if(object!=null&&!isKey(path,object)){path=toPath(path);object=path.length==1?object:baseGet(object,baseSlice(path,0,-1));result=object==null?undefined:object[last(path)];
}result=result===undefined?defaultValue:result}return isFunction(result)?result.call(object):result}module.exports=result},{"lodash._baseget":77,"lodash._baseslice":78,"lodash._topath":79,"lodash.isarray":48,"lodash.isfunction":57}],77:[function(require,module,exports){module.exports=require(37)},{}],78:[function(require,module,exports){module.exports=require(38)},{}],79:[function(require,module,exports){module.exports=require(39)},{"lodash.isarray":48}],80:[function(require,module,exports){var baseFlatten=require("lodash._baseflatten"),baseUniq=require("lodash._baseuniq"),restParam=require("lodash.restparam");var union=restParam(function(arrays){return baseUniq(baseFlatten(arrays,false,true))});module.exports=union},{"lodash._baseflatten":81,"lodash._baseuniq":83,"lodash.restparam":88}],81:[function(require,module,exports){module.exports=require(67)},{"lodash.isarguments":82,"lodash.isarray":48}],82:[function(require,module,exports){module.exports=require(7)},{}],83:[function(require,module,exports){var baseIndexOf=require("lodash._baseindexof"),cacheIndexOf=require("lodash._cacheindexof"),createCache=require("lodash._createcache");var LARGE_ARRAY_SIZE=200;function baseUniq(array,iteratee){var index=-1,indexOf=baseIndexOf,length=array.length,isCommon=true,isLarge=isCommon&&length>=LARGE_ARRAY_SIZE,seen=isLarge?createCache():null,result=[];if(seen){indexOf=cacheIndexOf;isCommon=false}else{isLarge=false;seen=iteratee?[]:result}outer:while(++index<length){var value=array[index],computed=iteratee?iteratee(value,index,array):value;if(isCommon&&value===value){var seenIndex=seen.length;while(seenIndex--){if(seen[seenIndex]===computed){continue outer}}if(iteratee){seen.push(computed)}result.push(value)}else if(indexOf(seen,computed,0)<0){if(iteratee||isLarge){seen.push(computed)}result.push(value)}}return result}module.exports=baseUniq},{"lodash._baseindexof":84,"lodash._cacheindexof":85,"lodash._createcache":86}],84:[function(require,module,exports){module.exports=require(42)},{}],85:[function(require,module,exports){module.exports=require(64)},{}],86:[function(require,module,exports){module.exports=require(65)},{"lodash._getnative":87}],87:[function(require,module,exports){module.exports=require(9)},{}],88:[function(require,module,exports){module.exports=require(21)},{}],89:[function(require,module,exports){(function(global){var INFINITY=1/0;var symbolTag="[object Symbol]";var objectProto=global.Object.prototype;var idCounter=0;var objectToString=objectProto.toString;var _Symbol=global.Symbol;var symbolProto=_Symbol?_Symbol.prototype:undefined,symbolToString=_Symbol?symbolProto.toString:undefined;function isObjectLike(value){return!!value&&typeof value=="object"}function isSymbol(value){return typeof value=="symbol"||isObjectLike(value)&&objectToString.call(value)==symbolTag}function toString(value){if(typeof value=="string"){return value}if(value==null){return""}if(isSymbol(value)){return _Symbol?symbolToString.call(value):""}var result=value+"";return result=="0"&&1/value==-INFINITY?"-0":result}function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id}module.exports=uniqueId}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],"ampersand-state":[function(require,module,exports){"use strict";if(typeof window!=="undefined"){window.ampersand=window.ampersand||{};window.ampersand["ampersand-state"]=window.ampersand["ampersand-state"]||[];window.ampersand["ampersand-state"].push("4.8.2")}var uniqueId=require("lodash.uniqueid");var assign=require("lodash.assign");var cloneObj=function(obj){return assign({},obj)};var omit=require("lodash.omit");var escape=require("lodash.escape");var forOwn=require("lodash.forown");var includes=require("lodash.includes");var isString=require("lodash.isstring");var isObject=require("lodash.isobject");var isDate=require("lodash.isdate");var isFunction=require("lodash.isfunction");var _isEqual=require("lodash.isequal");var has=require("lodash.has");var result=require("lodash.result");var bind=require("lodash.bind");var union=require("lodash.union");var Events=require("ampersand-events");var KeyTree=require("key-tree-store");var arrayNext=require("array-next");var changeRE=/^change:/;function Base(attrs,options){options||(options={});this.cid||(this.cid=uniqueId("state"));this._events={};this._values={};this._definition=Object.create(this._definition);if(options.parse)attrs=this.parse(attrs,options);this.parent=options.parent;this.collection=options.collection;this._keyTree=new KeyTree;this._initCollections();this._initChildren();this._cache={};this._previousAttributes={};if(attrs)this.set(attrs,assign({silent:true,initial:true},options));this._changed={};if(this._derived)this._initDerived();if(options.init!==false)this.initialize.apply(this,arguments)}assign(Base.prototype,Events,{extraProperties:"ignore",idAttribute:"id",namespaceAttribute:"namespace",typeAttribute:"modelType",initialize:function(){return this},getId:function(){return this[this.idAttribute]},getNamespace:function(){return this[this.namespaceAttribute]},getType:function(){return this[this.typeAttribute]},isNew:function(){return this.getId()==null},escape:function(attr){return escape(this.get(attr))},isValid:function(options){return this._validate({},assign(options||{},{validate:true}))},parse:function(resp,options){return resp},serialize:function(options){var attrOpts=assign({props:true},options);var res=this.getAttributes(attrOpts,true);forOwn(this._children,function(value,key){res[key]=this[key].serialize()},this);forOwn(this._collections,function(value,key){res[key]=this[key].serialize()},this);return res},set:function(key,value,options){var self=this;var extraProperties=this.extraProperties;var changing,changes,newType,newVal,def,cast,err,attr,attrs,dataType,silent,unset,currentVal,initial,hasChanged,isEqual;if(isObject(key)||key===null){attrs=key;options=value}else{attrs={};attrs[key]=value}options=options||{};if(!this._validate(attrs,options))return false;unset=options.unset;silent=options.silent;initial=options.initial;changes=[];changing=this._changing;this._changing=true;if(!changing){this._previousAttributes=this.attributes;this._changed={}}for(attr in attrs){newVal=attrs[attr];newType=typeof newVal;currentVal=this._values[attr];def=this._definition[attr];if(!def){if(this._children[attr]||this._collections[attr]){this[attr].set(newVal,options);continue}else if(extraProperties==="ignore"){continue}else if(extraProperties==="reject"){throw new TypeError('No "'+attr+'" property defined on '+(this.type||"this")+' model and extraProperties not set to "ignore" or "allow"')}else if(extraProperties==="allow"){def=this._createPropertyDefinition(attr,"any")}else if(extraProperties){throw new TypeError('Invalid value for extraProperties: "'+extraProperties+'"')}}isEqual=this._getCompareForType(def.type);dataType=this._dataTypes[def.type];if(dataType&&dataType.set){cast=dataType.set(newVal);newVal=cast.val;newType=cast.type}if(def.test){err=def.test.call(this,newVal,newType);if(err){throw new TypeError("Property '"+attr+"' failed validation with error: "+err)}}if(newVal===undefined&&def.required){throw new TypeError("Required property '"+attr+"' must be of type "+def.type+". Tried to set "+newVal)}if(newVal===null&&def.required&&!def.allowNull){throw new TypeError("Property '"+attr+"' must be of type "+def.type+" (cannot be null). Tried to set "+newVal)}if(def.type&&def.type!=="any"&&def.type!==newType&&newVal!==null&&newVal!==undefined){throw new TypeError("Property '"+attr+"' must be of type "+def.type+". Tried to set "+newVal)}if(def.values&&!includes(def.values,newVal)){var defaultValue=result(def,"default");if(unset&&defaultValue!==undefined){newVal=defaultValue}else if(!unset||unset&&newVal!==undefined){throw new TypeError("Property '"+attr+"' must be one of values: "+def.values.join(", ")+". Tried to set "+newVal)}}hasChanged=!isEqual(currentVal,newVal,attr);if(def.setOnce&&currentVal!==undefined&&hasChanged&&!initial){throw new TypeError("Property '"+attr+"' can only be set once.")}if(hasChanged){changes.push({prev:currentVal,val:newVal,key:attr});self._changed[attr]=newVal}else{delete self._changed[attr]}}changes.forEach(function(change){self._previousAttributes[change.key]=change.prev;if(unset){delete self._values[change.key]}else{self._values[change.key]=change.val}});if(!silent&&changes.length)self._pending=true;if(!silent){changes.forEach(function(change){self.trigger("change:"+change.key,self,change.val,options)})}if(changing)return this;if(!silent){while(this._pending){this._pending=false;this.trigger("change",this,options)}}this._pending=false;this._changing=false;return this},get:function(attr){return this[attr]},toggle:function(property){var def=this._definition[property];if(def.type==="boolean"){this[property]=!this[property]}else if(def&&def.values){this[property]=arrayNext(def.values,this[property])}else{throw new TypeError("Can only toggle properties that are type `boolean` or have `values` array.")}return this},previousAttributes:function(){return cloneObj(this._previousAttributes)},hasChanged:function(attr){if(attr==null)return!!Object.keys(this._changed).length;if(has(this._derived,attr)){return this._derived[attr].depList.some(function(dep){return this.hasChanged(dep)},this)}return has(this._changed,attr)},changedAttributes:function(diff){if(!diff)return this.hasChanged()?cloneObj(this._changed):false;var val,changed=false;var old=this._changing?this._previousAttributes:this.attributes;var def,isEqual;for(var attr in diff){def=this._definition[attr];if(!def)continue;isEqual=this._getCompareForType(def.type);if(isEqual(old[attr],val=diff[attr]))continue;(changed||(changed={}))[attr]=val}return changed},toJSON:function(){return this.serialize()},unset:function(attrs,options){var self=this;attrs=Array.isArray(attrs)?attrs:[attrs];attrs.forEach(function(key){var def=self._definition[key];if(!def)return;var val;if(def.required){val=result(def,"default");return self.set(key,val,options)}else{return self.set(key,val,assign({},options,{unset:true}))}})},clear:function(options){var self=this;Object.keys(this.attributes).forEach(function(key){self.unset(key,options)});return this},previous:function(attr){if(attr==null||!Object.keys(this._previousAttributes).length)return null;return this._previousAttributes[attr]},_getDefaultForType:function(type){var dataType=this._dataTypes[type];return dataType&&dataType["default"]},_getCompareForType:function(type){var dataType=this._dataTypes[type];if(dataType&&dataType.compare)return bind(dataType.compare,this);return _isEqual},_validate:function(attrs,options){if(!options.validate||!this.validate)return true;attrs=assign({},this.attributes,attrs);var error=this.validationError=this.validate(attrs,options)||null;if(!error)return true;this.trigger("invalid",this,error,assign(options||{},{validationError:error}));return false},_createPropertyDefinition:function(name,desc,isSession){return createPropertyDefinition(this,name,desc,isSession)},_ensureValidType:function(type){return includes(["string","number","boolean","array","object","date","state","any"].concat(Object.keys(this._dataTypes)),type)?type:undefined},getAttributes:function(options,raw){options=assign({session:false,props:false,derived:false},options||{});var res={};var val,item,def;for(item in this._definition){def=this._definition[item];if(options.session&&def.session||options.props&&!def.session){val=raw?this._values[item]:this[item];if(raw&&val&&isFunction(val.serialize))val=val.serialize();if(typeof val==="undefined")val=result(def,"default");if(typeof val!=="undefined")res[item]=val}}if(options.derived){for(item in this._derived)res[item]=this[item]}return res},_initDerived:function(){var self=this;forOwn(this._derived,function(value,name){var def=self._derived[name];def.deps=def.depList;var update=function(options){options=options||{};var newVal=def.fn.call(self);if(self._cache[name]!==newVal||!def.cache){if(def.cache){self._previousAttributes[name]=self._cache[name]}self._cache[name]=newVal;self.trigger("change:"+name,self,self._cache[name])}};def.deps.forEach(function(propString){self._keyTree.add(propString,update)})});this.on("all",function(eventName){if(changeRE.test(eventName)){self._keyTree.get(eventName.split(":")[1]).forEach(function(fn){fn()})}},this)},_getDerivedProperty:function(name,flushCache){if(this._derived[name].cache){if(flushCache||!this._cache.hasOwnProperty(name)){this._cache[name]=this._derived[name].fn.apply(this)}return this._cache[name]}else{return this._derived[name].fn.apply(this)}},_initCollections:function(){var coll;if(!this._collections)return;for(coll in this._collections){this._safeSet(coll,new this._collections[coll](null,{parent:this}))}},_initChildren:function(){var child;if(!this._children)return;for(child in this._children){this._safeSet(child,new this._children[child]({},{parent:this}));this.listenTo(this[child],"all",this._getEventBubblingHandler(child))}},_getEventBubblingHandler:function(propertyName){return bind(function(name,model,newValue){if(changeRE.test(name)){this.trigger("change:"+propertyName+"."+name.split(":")[1],model,newValue)}else if(name==="change"){this.trigger("change",this)}},this)},_verifyRequired:function(){var attrs=this.attributes;for(var def in this._definition){if(this._definition[def].required&&typeof attrs[def]==="undefined"){return false}}return true},_safeSet:function safeSet(property,value){if(property in this){throw new Error("Encountered namespace collision while setting instance property `"+property+"`")}this[property]=value;return this}});Object.defineProperties(Base.prototype,{attributes:{get:function(){return this.getAttributes({props:true,session:true})}},all:{get:function(){return this.getAttributes({session:true,props:true,derived:true})}},isState:{get:function(){return true},set:function(){}}});function createPropertyDefinition(object,name,desc,isSession){var def=object._definition[name]={};var type,descArray;if(isString(desc)){type=object._ensureValidType(desc);if(type)def.type=type}else{if(Array.isArray(desc)){descArray=desc;desc={type:descArray[0],required:descArray[1],"default":descArray[2]}}type=object._ensureValidType(desc.type);if(type)def.type=type;if(desc.required)def.required=true;if(desc["default"]&&typeof desc["default"]==="object"){throw new TypeError("The default value for "+name+" cannot be an object/array, must be a value or a function which returns a value/object/array")}def["default"]=desc["default"];def.allowNull=desc.allowNull?desc.allowNull:false;if(desc.setOnce)def.setOnce=true;if(def.required&&def["default"]===undefined&&!def.setOnce)def["default"]=object._getDefaultForType(type);def.test=desc.test;def.values=desc.values}if(isSession)def.session=true;if(!type){type=isString(desc)?desc:desc.type;console.warn("Invalid data type of `"+type+"` for `"+name+"` property. Use one of the default types or define your own")}Object.defineProperty(object,name,{set:function(val){this.set(name,val)},get:function(){if(!this._values){throw Error('You may be trying to `extend` a state object with "'+name+'" which has been defined in `props` on the object being extended')}var value=this._values[name];var typeDef=this._dataTypes[def.type];if(typeof value!=="undefined"){if(typeDef&&typeDef.get){value=typeDef.get(value)}return value}value=result(def,"default");this._values[name]=value;return value}});return def}function createDerivedProperty(modelProto,name,definition){var def=modelProto._derived[name]={fn:isFunction(definition)?definition:definition.fn,cache:definition.cache!==false,depList:definition.deps||[]};def.depList.forEach(function(dep){modelProto._deps[dep]=union(modelProto._deps[dep]||[],[name])});Object.defineProperty(modelProto,name,{get:function(){return this._getDerivedProperty(name)},set:function(){throw new TypeError("`"+name+"` is a derived property, it can't be set directly.")}})}var dataTypes={string:{"default":function(){return""}},date:{set:function(newVal){var newType;if(newVal==null){newType=typeof null}else if(!isDate(newVal)){var err=null;var dateVal=new Date(newVal).valueOf();if(isNaN(dateVal)){dateVal=new Date(parseInt(newVal,10)).valueOf();if(isNaN(dateVal))err=true}newVal=dateVal;newType="date";if(err){newType=typeof newVal}}else{newType="date";newVal=newVal.valueOf()}return{val:newVal,type:newType}},get:function(val){if(val==null){return val}return new Date(val)},"default":function(){return new Date}},array:{set:function(newVal){return{val:newVal,type:Array.isArray(newVal)?"array":typeof newVal}},"default":function(){return[]}},object:{set:function(newVal){var newType=typeof newVal;if(newType!=="object"&&newVal===undefined){newVal=null;newType="object"}return{val:newVal,type:newType}},"default":function(){return{}}},state:{set:function(newVal){var isInstance=newVal instanceof Base||newVal&&newVal.isState;if(isInstance){return{val:newVal,type:"state"}}else{return{val:newVal,type:typeof newVal}}},compare:function(currentVal,newVal,attributeName){var isSame=currentVal===newVal;if(!isSame){if(currentVal){this.stopListening(currentVal)}if(newVal!=null){this.listenTo(newVal,"all",this._getEventBubblingHandler(attributeName))}}return isSame}}};function extend(protoProps){var parent=this;var child;if(protoProps&&protoProps.hasOwnProperty("constructor")){child=protoProps.constructor}else{child=function(){return parent.apply(this,arguments)}}assign(child,parent);var Surrogate=function(){this.constructor=child};Surrogate.prototype=parent.prototype;child.prototype=new Surrogate;child.prototype._derived=assign({},parent.prototype._derived);child.prototype._deps=assign({},parent.prototype._deps);child.prototype._definition=assign({},parent.prototype._definition);child.prototype._collections=assign({},parent.prototype._collections);child.prototype._children=assign({},parent.prototype._children);child.prototype._dataTypes=assign({},parent.prototype._dataTypes||dataTypes);if(protoProps){var omitFromExtend=["dataTypes","props","session","derived","collections","children"];for(var i=0;i<arguments.length;i++){var def=arguments[i];if(def.dataTypes){forOwn(def.dataTypes,function(def,name){child.prototype._dataTypes[name]=def})}if(def.props){forOwn(def.props,function(def,name){createPropertyDefinition(child.prototype,name,def)})}if(def.session){forOwn(def.session,function(def,name){createPropertyDefinition(child.prototype,name,def,true)})}if(def.derived){forOwn(def.derived,function(def,name){createDerivedProperty(child.prototype,name,def)})}if(def.collections){forOwn(def.collections,function(constructor,name){child.prototype._collections[name]=constructor})}if(def.children){forOwn(def.children,function(constructor,name){child.prototype._children[name]=constructor})}assign(child.prototype,omit(def,omitFromExtend))}}child.__super__=parent.prototype;return child}Base.extend=extend;module.exports=Base},{"ampersand-events":1,"array-next":13,"key-tree-store":14,"lodash.assign":15,"lodash.bind":25,"lodash.escape":29,"lodash.forown":30,"lodash.has":36,"lodash.includes":41,"lodash.isdate":49,"lodash.isequal":50,"lodash.isfunction":57,"lodash.isobject":58,"lodash.isstring":59,"lodash.omit":60,"lodash.result":76,"lodash.union":80,"lodash.uniqueid":89}]},{},[]);var State=require("ampersand-state");var Collection=require("ampersand-collection");var Instance=State.extend({props:{id:"number",slug:"string",name:"string"},collections:{children:Collection.extend({model:Instance})}});var instance=new Instance({id:1,slug:"top",name:"Top",children:[{id:2,slug:"child-1",name:"Child 1",children:[{id:3,slug:"grand-child-3",name:"Grand Child 3"}]}]});console.log(instance.children instanceof Collection);console.log(instance.children.models[0].children instanceof Collection);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"ampersand-collection": "1.5.0",
"ampersand-state": "4.8.2"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment