Skip to content

Instantly share code, notes, and snippets.

@sholtomaud
Created February 3, 2016 01:58
Show Gist options
  • Save sholtomaud/eedb90614f416a25a020 to your computer and use it in GitHub Desktop.
Save sholtomaud/eedb90614f416a25a020 to your computer and use it in GitHub Desktop.
requirebin sketch
var fastn = require('fastn')({
list: require('fastn/listComponent'),
text: require('fastn/textComponent'),
templater: require('fastn/templaterComponent'),
_generic: require('fastn/genericComponent')
}, true);
var app = fastn('div',
fastn('button',{
class: 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect'
},
fastn('i', {class: 'material-icons' }, 'airplay')
),
fastn('button',{
class: 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect'
},
fastn('i', {class: 'material-icons' }, 'android')
),
fastn('button',{
class: 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect'
},
fastn('i', {class: 'material-icons' }, 'save')
),
fastn('button',{
class: 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect'
},
fastn('i', {class: 'material-icons' }, 'battery_charging_full')
)
);
app.render();
document.body.appendChild(app.element);
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 is=require("./is"),GENERIC="_generic",EventEmitter=require("events").EventEmitter,slice=Array.prototype.slice;function flatten(item){return Array.isArray(item)?item.reduce(function(result,element){if(element==null){return result}return result.concat(flatten(element))},[]):item}function attachProperties(object,firm){for(var key in this._properties){this._properties[key].attach(object,firm)}}function onRender(){this.attach(undefined,0);for(var key in this._properties){this._properties[key].update()}}function detachProperties(firm){for(var key in this._properties){this._properties[key].detach(firm)}}function destroyProperties(){for(var key in this._properties){this._properties[key].destroy()}}function clone(){return this.fastn(this.component._type,this.component._settings,this.component._children.filter(function(child){return!child._templated}).map(function(child){return child.clone()}))}function getSetBinding(newBinding){if(!arguments.length){return this.binding}if(!is.binding(newBinding)){newBinding=this.fastn.binding(newBinding)}if(this.binding&&this.binding!==newBinding){this.binding.removeListener("change",this.emitAttach);newBinding.attach(this.binding._model,this.binding._firm)}this.binding=newBinding;this.binding.on("change",this.emitAttach);this.binding.on("detach",this.emitDetach);this.emitAttach();return this.component}function emitAttach(){var newBound=this.binding();if(newBound!==this.lastBound){this.lastBound=newBound;this.scope.attach(this.lastBound);this.component.emit("attach",this.scope,1)}}function emitDetach(){this.component.emit("detach",1)}function getScope(){return this.scope}function destroy(){if(this.destroyed){return}this.destroyed=true;this.component.removeAllListeners("render").removeAllListeners("attach");this.component.emit("destroy");this.component.element=null;this.scope.destroy();this.binding.destroy();return this.component}function attachComponent(object,firm){this.binding.attach(object,firm);return this.component}function detachComponent(firm){this.binding.detach(firm);return this.component}function isDestroyed(){return this.destroyed}function setProperty(key,property){if(!property){property=this.component[key]||this.fastn.property()}this.component[key]=property;this.component._properties[key]=property;return this.component}function extendComponent(type,settings,children){if(type in this.types){return this.component}if(!(type in this.fastn.components)){if(!(GENERIC in this.fastn.components)){throw new Error('No component of type "'+type+'" is loaded')}this.fastn.components._generic(this.fastn,this.component,type,settings,children);this.types._generic=true}else{this.fastn.components[type](this.fastn,this.component,type,settings,children)}this.types[type]=true;return this.component}function isType(type){return type in this.types}function FastnComponent(fastn,type,settings,children){var component=this;var componentScope={types:{},fastn:fastn,component:component,binding:fastn.binding("."),destroyed:false,scope:new fastn.Model(false),lastBound:null};componentScope.emitAttach=emitAttach.bind(componentScope);componentScope.emitDetach=emitDetach.bind(componentScope);componentScope.binding._default_binding=true;component._type=type;component._properties={};component._settings=settings||{};component._children=children?flatten(children):[];component.attach=attachComponent.bind(componentScope);component.detach=detachComponent.bind(componentScope);component.scope=getScope.bind(componentScope);component.destroy=destroy.bind(componentScope);component.destroyed=isDestroyed.bind(componentScope);component.binding=getSetBinding.bind(componentScope);component.setProperty=setProperty.bind(componentScope);component.clone=clone.bind(componentScope);component.children=slice.bind(component._children);component.extend=extendComponent.bind(componentScope);component.is=isType.bind(componentScope);component.binding(componentScope.binding);component.on("attach",attachProperties.bind(this));component.on("render",onRender.bind(this));component.on("detach",detachProperties.bind(this));component.on("destroy",destroyProperties.bind(this));if(fastn.debug){component.on("render",function(){if(component.element&&typeof component.element==="object"){component.element._component=component}})}}FastnComponent.prototype=Object.create(EventEmitter.prototype);FastnComponent.prototype.constructor=FastnComponent;FastnComponent.prototype._fastn_component=true;module.exports=FastnComponent},{"./is":6,events:21}],2:[function(require,module,exports){var Enti=require("enti"),is=require("./is"),firmer=require("./firmer"),functionEmitter=require("./functionEmitter"),setPrototypeOf=require("setprototypeof"),same=require("same-value");function fuseBinding(){var args=Array.prototype.slice.call(arguments);var bindings=args.slice(),transform=bindings.pop(),updateTransform,resultBinding=createBinding("result"),selfChanging;resultBinding._arguments=args;if(typeof bindings[bindings.length-1]==="function"&&!is.binding(bindings[bindings.length-1])){updateTransform=transform;transform=bindings.pop()}resultBinding._model.removeAllListeners();resultBinding._set=function(value){if(updateTransform){selfChanging=true;var newValue=updateTransform(value);if(!same(newValue,bindings[0]())){bindings[0](newValue);resultBinding._change(newValue)}selfChanging=false}else{resultBinding._change(value)}};function change(){if(selfChanging){return}resultBinding(transform.apply(null,bindings.map(function(binding){return binding()})))}bindings.forEach(function(binding,index){if(!is.binding(binding)){binding=createBinding(binding);bindings.splice(index,1,binding)}binding.on("change",change);resultBinding.on("detach",binding.detach)});var lastAttached;resultBinding.on("attach",function(object){selfChanging=true;bindings.forEach(function(binding){binding.attach(object,1)});selfChanging=false;if(lastAttached!==object){change()}lastAttached=object});return resultBinding}function createValueBinding(){var valueBinding=createBinding("value");valueBinding.attach=function(){return valueBinding};valueBinding.detach=function(){return valueBinding};return valueBinding}function bindingTemplate(newValue){if(!arguments.length){return this.value}if(this.binding._fastn_binding==="."){return}this.binding._set(newValue);return this.binding}function createBinding(path,more){if(more){return fuseBinding.apply(null,arguments)}if(path==null){return createValueBinding()}var bindingScope={},binding=bindingScope.binding=bindingTemplate.bind(bindingScope),destroyed;setPrototypeOf(binding,functionEmitter);binding.setMaxListeners(1e4);binding._arguments=[path];binding._model=new Enti(false);binding._fastn_binding=path;binding._firm=-Infinity;function modelAttachHandler(data){binding._model.attach(data);binding._change(binding._model.get(path));binding.emit("attach",data,1)}function modelDetachHandler(){binding._model.detach()}binding.attach=function(object,firm){if(firmer(binding,firm)){return binding}binding._firm=firm;var isEnti=Enti.isEnti(object);if(isEnti&&bindingScope.attachedModel===object){return binding}if(bindingScope.attachedModel){bindingScope.attachedModel.removeListener("attach",modelAttachHandler);bindingScope.attachedModel.removeListener("detach",modelDetachHandler);bindingScope.attachedModel=null}if(isEnti){bindingScope.attachedModel=object;bindingScope.attachedModel.on("attach",modelAttachHandler);bindingScope.attachedModel.on("detach",modelDetachHandler);object=object._model}if(!(object instanceof Object)){object={}}if(binding._model._model===object){return binding}modelAttachHandler(object);return binding};binding.detach=function(firm){if(firmer(binding,firm)){return binding}bindingScope.value=undefined;if(binding._model.isAttached()){binding._model.detach()}binding.emit("detach",1);return binding};binding._set=function(newValue){if(same(binding._model.get(path),newValue)){return}if(!binding._model.isAttached()){binding._model.attach(binding._model.get("."))}binding._model.set(path,newValue)};binding._change=function(newValue){bindingScope.value=newValue;binding.emit("change",binding())};binding.clone=function(keepAttachment){var newBinding=createBinding.apply(null,binding._arguments);if(keepAttachment){newBinding.attach(bindingScope.attachedModel||binding._model._model,binding._firm)}return newBinding};binding.destroy=function(soft){if(destroyed){return}if(soft&&binding.listeners("change").length){return}destroyed=true;binding.emit("destroy");binding.detach();binding._model.destroy()};binding.destroyed=function(){return destroyed};if(path!=="."){binding._model.on(path,binding._change)}return binding}function from(valueOrBinding){if(is.binding(valueOrBinding)){return valueOrBinding}return createBinding()(valueOrBinding)}createBinding.from=from;module.exports=createBinding},{"./firmer":4,"./functionEmitter":5,"./is":6,enti:8,"same-value":10,setprototypeof:11}],3:[function(require,module,exports){function insertChild(fastn,container,child,index){var currentIndex=container._children.indexOf(child),newComponent=fastn.toComponent(child);if(newComponent!==child){container._children.splice(currentIndex,1,newComponent)}if(!~currentIndex||newComponent!==child){newComponent.attach(container.scope(),1)}if(currentIndex!==index){if(~currentIndex){container._children.splice(currentIndex,1)}container._children.splice(index,0,newComponent)}if(container.element){if(!newComponent.element){newComponent.render()}container._insert(newComponent.element,index);newComponent.emit("insert",container)}}function getContainerElement(){return this.containerElement||this.element}function insert(child,index){var childComponent=child,container=this.container,fastn=this.fastn;if(index&&typeof index==="object"){childComponent=Array.prototype.slice.call(arguments)}if(isNaN(index)){index=container._children.length}if(Array.isArray(childComponent)){for(var i=0;i<childComponent.length;i++){container.insert(childComponent[i],i+index)}}else{insertChild(fastn,container,childComponent,index)}return container}module.exports=function(fastn,component,type,settings,children){component.insert=insert.bind({container:component,fastn:fastn});component._insert=function(element,index){var containerElement=component.getContainerElement();if(!containerElement){return}if(containerElement.childNodes[index]===element){return}containerElement.insertBefore(element,containerElement.childNodes[index])};component.remove=function(childComponent){var index=component._children.indexOf(childComponent);if(~index){component._children.splice(index,1)}childComponent.detach(1);if(childComponent.element){component._remove(childComponent.element)}};component._remove=function(element){var containerElement=component.getContainerElement();if(!element||!containerElement||element.parentNode!==containerElement){return}containerElement.removeChild(element)};component.empty=function(){while(component._children.length){component.remove(component._children.pop())}};component.replaceChild=function(oldChild,newChild){var index=component._children.indexOf(oldChild);if(!~index){return}component.remove(oldChild);component.insert(newChild,index)};component.getContainerElement=getContainerElement.bind(component);component.on("render",component.insert.bind(null,component._children,0));component.on("attach",function(model,firm){for(var i=0;i<component._children.length;i++){if(fastn.isComponent(component._children[i])){component._children[i].attach(model,firm)}}});component.on("destroy",function(data,firm){for(var i=0;i<component._children.length;i++){if(fastn.isComponent(component._children[i])){component._children[i].destroy(firm)}}});return component}},{}],4:[function(require,module,exports){module.exports=function(entity,firm){if(firm!=null&&(entity._firm===undefined||firm<entity._firm)){return true}}},{}],5:[function(require,module,exports){var EventEmitter=require("events").EventEmitter,functionEmitterPrototype=function(){};for(var key in EventEmitter.prototype){functionEmitterPrototype[key]=EventEmitter.prototype[key]}module.exports=functionEmitterPrototype},{events:21}],6:[function(require,module,exports){var FUNCTION="function",OBJECT="object",FASTNBINDING="_fastn_binding",FASTNPROPERTY="_fastn_property",FASTNCOMPONENT="_fastn_component",DEFAULTBINDING="_default_binding";function isComponent(thing){return thing&&typeof thing===OBJECT&&FASTNCOMPONENT in thing}function isBindingObject(thing){return thing&&typeof thing===OBJECT&&FASTNBINDING in thing}function isBinding(thing){return typeof thing===FUNCTION&&FASTNBINDING in thing}function isProperty(thing){return typeof thing===FUNCTION&&FASTNPROPERTY in thing}function isDefaultBinding(thing){return typeof thing===FUNCTION&&FASTNBINDING in thing&&DEFAULTBINDING in thing}module.exports={component:isComponent,bindingObject:isBindingObject,binding:isBinding,defaultBinding:isDefaultBinding,property:isProperty}},{}],7:[function(require,module,exports){(function(root,factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{root.crel=factory()}})(this,function(){var fn="function",obj="object",nodeType="nodeType",textContent="textContent",setAttribute="setAttribute",attrMapString="attrMap",isNodeString="isNode",isElementString="isElement",d=typeof document===obj?document:{},isType=function(a,type){return typeof a===type},isNode=typeof Node===fn?function(object){return object instanceof Node}:function(object){return object&&isType(object,obj)&&nodeType in object&&isType(object.ownerDocument,obj)},isElement=function(object){return crel[isNodeString](object)&&object[nodeType]===1},isArray=function(a){return a instanceof Array},appendChild=function(element,child){if(!crel[isNodeString](child)){child=d.createTextNode(child)}element.appendChild(child)};function crel(){var args=arguments,element=args[0],child,settings=args[1],childIndex=2,argumentsLength=args.length,attributeMap=crel[attrMapString];element=crel[isElementString](element)?element:d.createElement(element);if(argumentsLength===1){return element}if(!isType(settings,obj)||crel[isNodeString](settings)||isArray(settings)){--childIndex;settings=null}if(argumentsLength-childIndex===1&&isType(args[childIndex],"string")&&element[textContent]!==undefined){element[textContent]=args[childIndex]}else{for(;childIndex<argumentsLength;++childIndex){child=args[childIndex];if(child==null){continue}if(isArray(child)){for(var i=0;i<child.length;++i){appendChild(element,child[i])}}else{appendChild(element,child)}}}for(var key in settings){if(!attributeMap[key]){element[setAttribute](key,settings[key])}else{var attr=attributeMap[key];if(typeof attr===fn){attr(element,settings[key])}else{element[setAttribute](attr,settings[key])}}}return element}crel[attrMapString]={};crel[isElementString]=isElement;crel[isNodeString]=isNode;return crel})},{}],8:[function(require,module,exports){(function(global){var EventEmitter=require("events").EventEmitter;function toArray(items){return Array.prototype.slice.call(items)}var deepRegex=/[|.]/i;function matchDeep(path){return(path+"").match(deepRegex)}function isWildcardPath(path){var stringPath=path+"";return~stringPath.indexOf("*")}function getTargetKey(path){var stringPath=path+"";return stringPath.split("|").shift()}var eventSystemVersion=1,globalKey="_entiEventState"+eventSystemVersion;globalState=global[globalKey]=global[globalKey]||{instances:[]};var modifiedEnties=globalState.modifiedEnties=globalState.modifiedEnties||new Set,trackedObjects=globalState.trackedObjects=globalState.trackedObjects||new WeakMap;function leftAndRest(path){var stringPath=path+"";if(stringPath.slice(0,2)===".|"){return[".",stringPath.slice(2)]}var match=matchDeep(stringPath);if(match){return[stringPath.slice(0,match.index),stringPath.slice(match.index+1)]}return stringPath}function isWildcardKey(key){return key.charAt(0)==="*"}function isFeralcardKey(key){return key==="**"}function addHandler(object,key,handler){var trackedKeys=trackedObjects.get(object);if(trackedKeys==null){trackedKeys={};trackedObjects.set(object,trackedKeys)}var handlers=trackedKeys[key];if(!handlers){handlers=new Set;trackedKeys[key]=handlers}handlers.add(handler)}function removeHandler(object,key,handler){var trackedKeys=trackedObjects.get(object);if(trackedKeys==null){return}var handlers=trackedKeys[key];if(!handlers){return}handlers.delete(handler)}function trackObjects(eventName,tracked,handler,object,key,path){if(!object||typeof object!=="object"){return}var eventKey=key==="**"?"*":key,target=object[key],targetIsObject=target&&typeof target==="object";if(targetIsObject&&tracked.has(target)){return}var handle=function(value,event,emitKey){if(eventKey!=="*"&&typeof object[eventKey]==="object"&&object[eventKey]!==target){if(targetIsObject){tracked.delete(target)}removeHandler(object,eventKey,handle);trackObjects(eventName,tracked,handler,object,key,path);return}if(eventKey==="*"){trackKeys(object,key,path)}if(!tracked.has(object)){return}if(key!=="**"||!path){handler(value,event,emitKey)}};function trackKeys(target,root,rest){var keys=Object.keys(target);for(var i=0;i<keys.length;i++){if(isFeralcardKey(root)){trackObjects(eventName,tracked,handler,target,keys[i],"**"+(rest?".":"")+(rest||""))}else{trackObjects(eventName,tracked,handler,target,keys[i],rest)}}}addHandler(object,eventKey,handle);if(!targetIsObject){return}tracked.add(target);if(!path){return}var rootAndRest=leftAndRest(path),root,rest;if(!Array.isArray(rootAndRest)){root=rootAndRest}else{root=rootAndRest[0];rest=rootAndRest[1];if(root==="."){root="*"}}if(targetIsObject&&isWildcardKey(root)){trackKeys(target,root,rest)}trackObjects(eventName,tracked,handler,target,root,rest)}var trackedEvents=new WeakMap;function createHandler(enti,trackedObjectPaths,trackedPaths,eventName){var oldModel=enti._model;return function(event,emitKey){trackedPaths.entis.forEach(function(enti){if(enti._emittedEvents[eventName]===emitKey){return}if(enti._model!==oldModel){trackedPaths.entis.delete(enti);if(trackedPaths.entis.size===0){delete trackedObjectPaths[eventName];if(!Object.keys(trackedObjectPaths).length){trackedEvents.delete(oldModel)}}return}enti._emittedEvents[eventName]=emitKey;var targetKey=getTargetKey(eventName),value=isWildcardPath(targetKey)?undefined:enti.get(targetKey);enti.emit(eventName,value,event)})}}function trackPath(enti,eventName){var object=enti._model,trackedObjectPaths=trackedEvents.get(object);if(!trackedObjectPaths){trackedObjectPaths={};trackedEvents.set(object,trackedObjectPaths)}var trackedPaths=trackedObjectPaths[eventName];if(!trackedPaths){trackedPaths={entis:new Set,trackedObjects:new WeakSet};trackedObjectPaths[eventName]=trackedPaths}else if(trackedPaths.entis.has(enti)){return}trackedPaths.entis.add(enti);var handler=createHandler(enti,trackedObjectPaths,trackedPaths,eventName);trackObjects(eventName,trackedPaths.trackedObjects,handler,{model:object},"model",eventName)}function trackPaths(enti){if(!enti._events||!enti._model){return}for(var key in enti._events){trackPath(enti,key)}modifiedEnties.delete(enti)}function emitEvent(object,key,value,emitKey){modifiedEnties.forEach(trackPaths);var trackedKeys=trackedObjects.get(object);if(!trackedKeys){return}var event={value:value,key:key,object:object};function emitForKey(handler){handler(event,emitKey)}if(trackedKeys[key]){trackedKeys[key].forEach(emitForKey)}if(trackedKeys["*"]){trackedKeys["*"].forEach(emitForKey)}}function emit(events){var emitKey={};events.forEach(function(event){emitEvent(event[0],event[1],event[2],emitKey)})}function Enti(model){var detached=model===false;if(!model||typeof model!=="object"&&typeof model!=="function"){model={}}this._emittedEvents={};if(detached){this._model={}}else{this.attach(model)}this.on("newListener",function(){modifiedEnties.add(this)})}Enti.get=function(model,key){if(!model||typeof model!=="object"){return}key=getTargetKey(key);if(key==="."){return model}var path=leftAndRest(key);if(Array.isArray(path)){return Enti.get(model[path[0]],path[1])}return model[key]};Enti.set=function(model,key,value){if(!model||typeof model!=="object"){return}key=getTargetKey(key);var path=leftAndRest(key);if(Array.isArray(path)){return Enti.set(model[path[0]],path[1],value)}var original=model[key];if(typeof value!=="object"&&value===original){return}var keysChanged=!(key in model);model[key]=value;var events=[[model,key,value]];if(keysChanged){if(Array.isArray(model)){events.push([model,"length",model.length])}}emit(events)};Enti.push=function(model,key,value){if(!model||typeof model!=="object"){return}var target;if(arguments.length<3){value=key;key=".";target=model}else{var path=leftAndRest(key);if(Array.isArray(path)){return Enti.push(model[path[0]],path[1],value)}target=model[key]}if(!Array.isArray(target)){throw"The target is not an array."}target.push(value);var events=[[target,target.length-1,value],[target,"length",target.length]];emit(events)};Enti.insert=function(model,key,value,index){if(!model||typeof model!=="object"){return}var target;if(arguments.length<4){index=value;value=key;key=".";target=model}else{var path=leftAndRest(key);if(Array.isArray(path)){return Enti.insert(model[path[0]],path[1],value,index)}target=model[key]}if(!Array.isArray(target)){throw"The target is not an array."}target.splice(index,0,value);var events=[[target,index,value],[target,"length",target.length]];emit(events)};Enti.remove=function(model,key,subKey){if(!model||typeof model!=="object"){return}var path=leftAndRest(key);if(Array.isArray(path)){return Enti.remove(model[path[0]],path[1],subKey)}if(subKey!=null){Enti.remove(model[key],subKey);return}if(key==="."){throw". (self) is not a valid key to remove"}var events=[];if(Array.isArray(model)){model.splice(key,1);events.push([model,"length",model.length])}else{delete model[key];events.push([model,key])}emit(events)};Enti.move=function(model,key,index){if(!model||typeof model!=="object"){return}var path=leftAndRest(key);if(Array.isArray(path)){return Enti.move(model[path[0]],path[1],index)}if(key===index){return}if(!Array.isArray(model)){throw"The model is not an array."}var item=model[key];model.splice(key,1);model.splice(index-(index>key?0:1),0,item);emit([[model,index,item]])};Enti.update=function(model,key,value){if(!model||typeof model!=="object"){return}var target,isArray=Array.isArray(value);if(arguments.length<3){value=key;key=".";target=model}else{var path=leftAndRest(key);if(Array.isArray(path)){return Enti.update(model[path[0]],path[1],value)}target=model[key];if(target==null){model[key]=isArray?[]:{}}}if(typeof value!=="object"){throw"The value is not an object."}if(typeof target!=="object"){throw"The target is not an object."}var events=[],updatedObjects=new WeakSet;function updateTarget(target,value){for(var key in value){var currentValue=target[key];if(currentValue instanceof Object&&!updatedObjects.has(currentValue)){updatedObjects.add(currentValue);updateTarget(currentValue,value[key]);continue}target[key]=value[key];events.push([target,key,value[key]])}if(Array.isArray(target)){events.push([target,"length",target.length])}}updateTarget(target,value);emit(events)};Enti.prototype=Object.create(EventEmitter.prototype);Enti.prototype._maxListeners=100;Enti.prototype.constructor=Enti;Enti.prototype.attach=function(model){if(this._model!==model){this.detach()}modifiedEnties.add(this);this._attached=true;this._model=model;this.emit("attach",model)};Enti.prototype.detach=function(){modifiedEnties.delete(this);this._emittedEvents={};this._model={};this._attached=false;this.emit("detach")};Enti.prototype.destroy=function(){this.detach();this._events=null;this.emit("destroy")};Enti.prototype.get=function(key){return Enti.get(this._model,key)};Enti.prototype.set=function(key,value){return Enti.set(this._model,key,value)};Enti.prototype.push=function(key,value){return Enti.push.apply(null,[this._model].concat(toArray(arguments)))};Enti.prototype.insert=function(key,value,index){return Enti.insert.apply(null,[this._model].concat(toArray(arguments)))};Enti.prototype.remove=function(key,subKey){return Enti.remove.apply(null,[this._model].concat(toArray(arguments)))};Enti.prototype.move=function(key,index){return Enti.move.apply(null,[this._model].concat(toArray(arguments)))};Enti.prototype.update=function(key,index){return Enti.update.apply(null,[this._model].concat(toArray(arguments)))};Enti.prototype.isAttached=function(){return this._attached};Enti.prototype.attachedCount=function(){return modifiedEnties.size};Enti.isEnti=function(target){return target&&!!~globalState.instances.indexOf(target.constructor)};Enti.store=function(target,key,value){if(arguments.length<2){return Enti.get(target,key)}Enti.set(target,key,value)};globalState.instances.push(Enti);module.exports=Enti}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{events:21}],9:[function(require,module,exports){"use strict";var propIsEnumerable=Object.prototype.propertyIsEnumerable;function ToObject(val){if(val==null){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}function ownEnumerableKeys(obj){var keys=Object.getOwnPropertyNames(obj);if(Object.getOwnPropertySymbols){keys=keys.concat(Object.getOwnPropertySymbols(obj))}return keys.filter(function(key){return propIsEnumerable.call(obj,key)})}module.exports=Object.assign||function(target,source){var from;var keys;var to=ToObject(target);for(var s=1;s<arguments.length;s++){from=arguments[s];keys=ownEnumerableKeys(Object(from));for(var i=0;i<keys.length;i++){to[keys[i]]=from[keys[i]]}}return to}},{}],10:[function(require,module,exports){module.exports=function isSame(a,b){if(a===b){return true}if(typeof a!==typeof b||typeof a==="object"&&!(a instanceof Date&&b instanceof Date)){return false}return String(a)===String(b)}},{}],11:[function(require,module,exports){module.exports=Object.setPrototypeOf||{__proto__:[]}instanceof Array?setProtoOf:mixinProperties;function setProtoOf(obj,proto){obj.__proto__=proto}function mixinProperties(obj,proto){for(var prop in proto){obj[prop]=proto[prop]}}},{}],12:[function(require,module,exports){var clone=require("clone"),deepEqual=require("deep-equal");function keysAreDifferent(keys1,keys2){if(keys1===keys2){return}if(!keys1||!keys2||keys1.length!==keys2.length){return true}for(var i=0;i<keys1.length;i++){if(!~keys2.indexOf(keys1[i])){return true}}}function getKeys(value){if(!value||typeof value!=="object"){return}return Object.keys(value)}function WhatChanged(value,changesToTrack){this._changesToTrack={};if(changesToTrack==null){changesToTrack="value type keys structure reference"}if(typeof changesToTrack!=="string"){throw"changesToTrack must be of type string"}changesToTrack=changesToTrack.split(" ");for(var i=0;i<changesToTrack.length;i++){this._changesToTrack[changesToTrack[i]]=true}this.update(value)}WhatChanged.prototype.update=function(value){var result={},changesToTrack=this._changesToTrack,newKeys=getKeys(value);if("value"in changesToTrack&&value+""!==this._lastReference+""){result.value=true}if("type"in changesToTrack&&typeof value!==typeof this._lastValue||(value===null||this._lastValue===null)&&this.value!==this._lastValue){result.type=true}if("keys"in changesToTrack&&keysAreDifferent(this._lastKeys,getKeys(value))){result.keys=true}if(value!==null&&typeof value==="object"){var lastValue=this._lastValue;if("shallowStructure"in changesToTrack&&(!lastValue||typeof lastValue!=="object"||Object.keys(value).some(function(key,index){return value[key]!==lastValue[key]}))){result.shallowStructure=true}if("structure"in changesToTrack&&!deepEqual(value,lastValue)){result.structure=true}if("reference"in changesToTrack&&value!==this._lastReference){result.reference=true}}this._lastValue="structure"in changesToTrack?clone(value):"shallowStructure"in changesToTrack?clone(value,true,1):value;this._lastReference=value;this._lastKeys=newKeys;return result};module.exports=WhatChanged},{clone:13,"deep-equal":14}],13:[function(require,module,exports){(function(Buffer){var clone=function(){"use strict";function clone(parent,circular,depth,prototype){var filter;if(typeof circular==="object"){depth=circular.depth;prototype=circular.prototype;filter=circular.filter;circular=circular.circular}var allParents=[];var allChildren=[];var useBuffer=typeof Buffer!="undefined";if(typeof circular=="undefined")circular=true;if(typeof depth=="undefined")depth=Infinity;function _clone(parent,depth){if(parent===null)return null;if(depth==0)return parent;var child;var proto;if(typeof parent!="object"){return parent}if(clone.__isArray(parent)){child=[]}else if(clone.__isRegExp(parent)){child=new RegExp(parent.source,__getRegExpFlags(parent));if(parent.lastIndex)child.lastIndex=parent.lastIndex}else if(clone.__isDate(parent)){child=new Date(parent.getTime())}else if(useBuffer&&Buffer.isBuffer(parent)){child=new Buffer(parent.length);parent.copy(child);return child}else{if(typeof prototype=="undefined"){proto=Object.getPrototypeOf(parent);child=Object.create(proto)}else{child=Object.create(prototype);proto=prototype}}if(circular){var index=allParents.indexOf(parent);if(index!=-1){return allChildren[index]}allParents.push(parent);allChildren.push(child)}for(var i in parent){var attrs;if(proto){attrs=Object.getOwnPropertyDescriptor(proto,i)}if(attrs&&attrs.set==null){continue}child[i]=_clone(parent[i],depth-1)}return child}return _clone(parent,depth)}clone.clonePrototype=function clonePrototype(parent){if(parent===null)return null;var c=function(){};c.prototype=parent;return new c};function __objToStr(o){return Object.prototype.toString.call(o)}clone.__objToStr=__objToStr;function __isDate(o){return typeof o==="object"&&__objToStr(o)==="[object Date]"}clone.__isDate=__isDate;function __isArray(o){return typeof o==="object"&&__objToStr(o)==="[object Array]"}clone.__isArray=__isArray;function __isRegExp(o){return typeof o==="object"&&__objToStr(o)==="[object RegExp]"}clone.__isRegExp=__isRegExp;function __getRegExpFlags(re){var flags="";if(re.global)flags+="g";if(re.ignoreCase)flags+="i";if(re.multiline)flags+="m";return flags}clone.__getRegExpFlags=__getRegExpFlags;return clone}();if(typeof module==="object"&&module.exports){module.exports=clone}}).call(this,require("buffer").Buffer)},{buffer:18}],14:[function(require,module,exports){var pSlice=Array.prototype.slice;var objectKeys=require("./lib/keys.js");var isArguments=require("./lib/is_arguments.js");var deepEqual=module.exports=function(actual,expected,opts){if(!opts)opts={};if(actual===expected){return true}else if(actual instanceof Date&&expected instanceof Date){return actual.getTime()===expected.getTime()}else if(typeof actual!="object"&&typeof expected!="object"){return opts.strict?actual===expected:actual==expected}else{return objEquiv(actual,expected,opts)}};function isUndefinedOrNull(value){return value===null||value===undefined}function isBuffer(x){if(!x||typeof x!=="object"||typeof x.length!=="number")return false;if(typeof x.copy!=="function"||typeof x.slice!=="function"){return false}if(x.length>0&&typeof x[0]!=="number")return false;return true}function objEquiv(a,b,opts){var i,key;if(isUndefinedOrNull(a)||isUndefinedOrNull(b))return false;if(a.prototype!==b.prototype)return false;if(isArguments(a)){if(!isArguments(b)){return false}a=pSlice.call(a);b=pSlice.call(b);return deepEqual(a,b,opts)}if(isBuffer(a)){if(!isBuffer(b)){return false}if(a.length!==b.length)return false;for(i=0;i<a.length;i++){if(a[i]!==b[i])return false}return true;
}try{var ka=objectKeys(a),kb=objectKeys(b)}catch(e){return false}if(ka.length!=kb.length)return false;ka.sort();kb.sort();for(i=ka.length-1;i>=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!deepEqual(a[key],b[key],opts))return false}return typeof a===typeof b}},{"./lib/is_arguments.js":15,"./lib/keys.js":16}],15:[function(require,module,exports){var supportsArgumentsClass=function(){return Object.prototype.toString.call(arguments)}()=="[object Arguments]";exports=module.exports=supportsArgumentsClass?supported:unsupported;exports.supported=supported;function supported(object){return Object.prototype.toString.call(object)=="[object Arguments]"}exports.unsupported=unsupported;function unsupported(object){return object&&typeof object=="object"&&typeof object.length=="number"&&Object.prototype.hasOwnProperty.call(object,"callee")&&!Object.prototype.propertyIsEnumerable.call(object,"callee")||false}},{}],16:[function(require,module,exports){exports=module.exports=typeof Object.keys==="function"?Object.keys:shim;exports.shim=shim;function shim(obj){var keys=[];for(var key in obj)keys.push(key);return keys}},{}],17:[function(require,module,exports){var Enti=require("enti"),WhatChanged=require("what-changed"),same=require("same-value"),firmer=require("./firmer"),createBinding=require("./binding"),functionEmitter=require("./functionEmitter"),setPrototypeOf=require("setprototypeof"),is=require("./is");var propertyProto=Object.create(functionEmitter);propertyProto._fastn_property=true;propertyProto._firm=1;function propertyTemplate(value){if(!arguments.length){return this.binding&&this.binding()||this.property._value}if(!this.destroyed){if(this.binding){this.binding(value);return this.property}this.valueUpdate(value)}return this.property}function changeChecker(current,changes){if(changes){var changes=new WhatChanged(current,changes);return function(value){return Object.keys(changes.update(value)).length>0}}else{var lastValue=current;return function(newValue){if(!same(lastValue,newValue)){lastValue=newValue;return true}}}}function propertyBinding(newBinding){if(!arguments.length){return this.binding}if(!is.binding(newBinding)){newBinding=createBinding(newBinding)}if(newBinding===this.binding){return this.property}if(this.binding){this.binding.removeListener("change",this.valueUpdate)}this.binding=newBinding;if(this.model){this.property.attach(this.model,this.property._firm)}this.binding.on("change",this.valueUpdate);this.valueUpdate(this.binding());return this.property}function attachProperty(object,firm){if(firmer(this.property,firm)){return this.property}this.property._firm=firm;if(!(object instanceof Object)){object={}}if(this.binding){this.model=object;this.binding.attach(object,1)}if(this.property._events&&"attach"in this.property._events){this.property.emit("attach",object,1)}return this.property}function detachProperty(firm){if(firmer(this.property,firm)){return this.property}if(this.binding){this.binding.removeListener("change",this.valueUpdate);this.binding.detach(1);this.model=null}if(this.property._events&&"detach"in this.property._events){this.property.emit("detach",1)}return this.property}function updateProperty(){if(!this.destroyed){if(this.property._update){this.property._update(this.property._value,this.property)}this.property.emit("update",this.property._value)}return this.property}function propertyUpdater(fn){if(!arguments.length){return this.property._update}this.property._update=fn;return this.property}function destroyProperty(){if(!this.destroyed){this.destroyed=true;this.property.removeAllListeners("change").removeAllListeners("update").removeAllListeners("attach");this.property.emit("destroy");this.property.detach();if(this.binding){this.binding.destroy(true)}}return this.property}function propertyDestroyed(){return this.destroyed}function addPropertyTo(component,key){component.setProperty(key,this.property);return this.property}function createProperty(currentValue,changes,updater){if(typeof changes==="function"){updater=changes;changes=null}var propertyScope=property=propertyTemplate.bind(propertyScope);propertyScope={hasChanged:changeChecker(currentValue,changes),valueUpdate:function(value){property._value=value;if(!propertyScope.hasChanged(value)){return}property.emit("change",property._value);property.update()}};var property=propertyScope.property=propertyTemplate.bind(propertyScope);property._value=currentValue;property._update=updater;setPrototypeOf(property,propertyProto);property.binding=propertyBinding.bind(propertyScope);property.attach=attachProperty.bind(propertyScope);property.detach=detachProperty.bind(propertyScope);property.update=updateProperty.bind(propertyScope);property.updater=propertyUpdater.bind(propertyScope);property.destroy=destroyProperty.bind(propertyScope);property.destroyed=propertyDestroyed.bind(propertyScope);property.addTo=addPropertyTo.bind(propertyScope);return property}module.exports=createProperty},{"./binding":2,"./firmer":4,"./functionEmitter":5,"./is":6,enti:8,"same-value":10,setprototypeof:11,"what-changed":12}],18:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=Buffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){if(encoding==="base64")subject=base64clean(subject);length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new Error("First argument needs to be a number, array or string.");var buf;if(TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}return buf}Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.byteLength=function(str,encoding){var ret;str=str.toString();switch(encoding||"utf8"){case"hex":ret=str.length/2;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"ascii":case"binary":case"raw":ret=str.length;break;case"base64":ret=base64ToBytes(str).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;default:throw new Error("Unknown encoding")}return ret};Buffer.concat=function(list,totalLength){assert(isArray(list),"Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.compare=function(a,b){assert(Buffer.isBuffer(a)&&Buffer.isBuffer(b),"Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y){return-1}if(y<x){return 1}return 0};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;assert(strLen%2===0,"Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);assert(!isNaN(byte),"Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string),buf,offset,length);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toString=function(encoding,start,end){var self=this;encoding=String(encoding||"utf8").toLowerCase();start=Number(start)||0;end=end===undefined?self.length:Number(end);if(end===start)return"";var ret;switch(encoding){case"hex":ret=hexSlice(self,start,end);break;case"utf8":case"utf-8":ret=utf8Slice(self,start,end);break;case"ascii":ret=asciiSlice(self,start,end);break;case"binary":ret=binarySlice(self,start,end);break;case"base64":ret=base64Slice(self,start,end);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leSlice(self,start,end);break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Buffer.prototype.equals=function(b){assert(Buffer.isBuffer(b),"Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.compare=function(b){assert(Buffer.isBuffer(b),"Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(!target_start)target_start=0;if(end===start)return;if(target.length===0||source.length===0)return;assert(end>=start,"sourceEnd < sourceStart");assert(target_start>=0&&target_start<target.length,"targetStart out of bounds");assert(start>=0&&start<source.length,"sourceStart out of bounds");assert(end>=0&&end<=source.length,"sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<100||!TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function binarySlice(buf,start,end){return asciiSlice(buf,start,end)}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;if(TYPED_ARRAY_SUPPORT){return Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;var newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}return newBuf}};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;return this[offset]};function readUInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){val=buf[offset];if(offset+1<len)val|=buf[offset+1]<<8}else{val=buf[offset]<<8;if(offset+1<len)val|=buf[offset+1]}return val}Buffer.prototype.readUInt16LE=function(offset,noAssert){return readUInt16(this,offset,true,noAssert)};Buffer.prototype.readUInt16BE=function(offset,noAssert){return readUInt16(this,offset,false,noAssert)};function readUInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){if(offset+2<len)val=buf[offset+2]<<16;if(offset+1<len)val|=buf[offset+1]<<8;val|=buf[offset];if(offset+3<len)val=val+(buf[offset+3]<<24>>>0)}else{if(offset+1<len)val=buf[offset+1]<<16;if(offset+2<len)val|=buf[offset+2]<<8;if(offset+3<len)val|=buf[offset+3];val=val+(buf[offset]<<24>>>0)}return val}Buffer.prototype.readUInt32LE=function(offset,noAssert){return readUInt32(this,offset,true,noAssert)};Buffer.prototype.readUInt32BE=function(offset,noAssert){return readUInt32(this,offset,false,noAssert)};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;var neg=this[offset]&128;if(neg)return(255-this[offset]+1)*-1;else return this[offset]};function readInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=readUInt16(buf,offset,littleEndian,true);var neg=val&32768;if(neg)return(65535-val+1)*-1;else return val}Buffer.prototype.readInt16LE=function(offset,noAssert){return readInt16(this,offset,true,noAssert)};Buffer.prototype.readInt16BE=function(offset,noAssert){return readInt16(this,offset,false,noAssert)};function readInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=readUInt32(buf,offset,littleEndian,true);var neg=val&2147483648;if(neg)return(4294967295-val+1)*-1;else return val}Buffer.prototype.readInt32LE=function(offset,noAssert){return readInt32(this,offset,true,noAssert)};Buffer.prototype.readInt32BE=function(offset,noAssert){return readInt32(this,offset,false,noAssert)};function readFloat(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+3<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,23,4)}Buffer.prototype.readFloatLE=function(offset,noAssert){return readFloat(this,offset,true,noAssert)};Buffer.prototype.readFloatBE=function(offset,noAssert){return readFloat(this,offset,false,noAssert)};function readDouble(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+7<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,52,8)}Buffer.prototype.readDoubleLE=function(offset,noAssert){return readDouble(this,offset,true,noAssert)};Buffer.prototype.readDoubleBE=function(offset,noAssert){return readDouble(this,offset,false,noAssert)};Buffer.prototype.writeUInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"trying to write beyond buffer length");verifuint(value,255)}if(offset>=this.length)return;this[offset]=value;return offset+1};function writeUInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"trying to write beyond buffer length");verifuint(value,65535)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}return offset+2}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return writeUInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return writeUInt16(this,value,offset,false,noAssert)};function writeUInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"trying to write beyond buffer length");verifuint(value,4294967295)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}return offset+4}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return writeUInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return writeUInt32(this,value,offset,false,noAssert)};Buffer.prototype.writeInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to write beyond buffer length");verifsint(value,127,-128)}if(offset>=this.length)return;if(value>=0)this.writeUInt8(value,offset,noAssert);else this.writeUInt8(255+value+1,offset,noAssert);return offset+1};function writeInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to write beyond buffer length");verifsint(value,32767,-32768)}var len=buf.length;if(offset>=len)return;if(value>=0)writeUInt16(buf,value,offset,littleEndian,noAssert);else writeUInt16(buf,65535+value+1,offset,littleEndian,noAssert);return offset+2}Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return writeInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return writeInt16(this,value,offset,false,noAssert)};function writeInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifsint(value,2147483647,-2147483648)}var len=buf.length;if(offset>=len)return;if(value>=0)writeUInt32(buf,value,offset,littleEndian,noAssert);else writeUInt32(buf,4294967295+value+1,offset,littleEndian,noAssert);return offset+4}Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return writeInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return writeInt32(this,value,offset,false,noAssert)};function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,3.4028234663852886e38,-3.4028234663852886e38)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+7<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,1.7976931348623157e308,-1.7976931348623157e308)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;assert(end>=start,"end < start");if(end===start)return;if(this.length===0)return;assert(start>=0&&start<this.length,"start out of bounds");assert(end>=0&&end<=this.length,"end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.inspect=function(){var out=[];var len=this.length;for(var i=0;i<len;i++){out[i]=toHex(this[i]);if(i===exports.INSPECT_MAX_BYTES){out[i+1]="...";break}}return"<Buffer "+out.join(" ")+">"};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new Error("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArray(subject){return(Array.isArray||function(subject){return Object.prototype.toString.call(subject)==="[object Array]"})(subject)}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){var b=str.charCodeAt(i);if(b<=127){byteArray.push(b)}else{var start=i;if(b>=55296&&b<=57343)i++;var h=encodeURIComponent(str.slice(start,i+1)).substr(1).split("%");for(var j=0;j<h.length;j++){byteArray.push(parseInt(h[j],16))}}}return byteArray}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(str)}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}function verifuint(value,max){assert(typeof value==="number","cannot write a non-number as a number");assert(value>=0,"specified a negative value for writing an unsigned value");assert(value<=max,"value is larger than maximum value for type");assert(Math.floor(value)===value,"value has a fractional component")}function verifsint(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value");assert(Math.floor(value)===value,"value has a fractional component")}function verifIEEE754(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value")}function assert(test,message){if(!test)throw new Error(message||"Failed assertion")}},{"base64-js":19,ieee754:20}],19:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS)return 62;if(code===SLASH)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],20:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],21:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){
er=arguments[1];if(er instanceof Error){throw er}else{throw TypeError('Uncaught, unspecified "error" event.')}return false}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],fastn:[function(require,module,exports){var createProperty=require("./property"),createBinding=require("./binding"),BaseComponent=require("./baseComponent"),crel=require("crel"),Enti=require("enti"),objectAssign=require("object-assign"),is=require("./is");function inflateProperties(component,settings){for(var key in settings){var setting=settings[key],property=component[key];if(is.property(settings[key])){if(is.property(property)){property.destroy()}setting.addTo(component,key)}else if(is.property(property)){if(is.binding(setting)){property.binding(setting)}else{property(setting)}property.addTo(component,key)}}}function validateExpectedComponents(components,componentName,expectedComponents){expectedComponents=expectedComponents.filter(function(componentName){return!(componentName in components)});if(expectedComponents.length){console.warn(['fastn("'+componentName+'") uses some components that have not been registered with fastn',"Expected conponent constructors: "+expectedComponents.join(", ")].join("\n\n"))}}module.exports=function(components,debug){if(!components||typeof components!=="object"){throw new Error("fastn must be initialised with a components object")}components._container=components._container||require("./containerComponent");function fastn(type){var args=[];for(var i=0;i<arguments.length;i++){args[i]=arguments[i]}var settings=args[1],childrenIndex=2,settingsChild=fastn.toComponent(args[1]);if(Array.isArray(args[1])||settingsChild||!args[1]){args[1]=settingsChild||args[1];childrenIndex--;settings=null}settings=objectAssign({},settings||{});var types=typeof type==="string"?type.split(":"):Array.isArray(type)?type:[type],baseType,children=args.slice(childrenIndex),component=fastn.base(type,settings,children);while(baseType=types.shift()){component.extend(baseType,settings,children)}component._properties={};inflateProperties(component,settings);return component}fastn.toComponent=function(component){if(component==null){return}if(is.component(component)){return component}if(typeof component!=="object"||component instanceof Date){return fastn("text",{auto:true},component)}if(crel.isElement(component)){return fastn(component)}if(crel.isNode(component)){return fastn("text",{auto:true},component.textContent)}};fastn.debug=debug;fastn.property=createProperty;fastn.binding=createBinding;fastn.isComponent=is.component;fastn.isBinding=is.binding;fastn.isDefaultBinding=is.defaultBinding;fastn.isBindingObject=is.bindingObject;fastn.isProperty=is.property;fastn.components=components;fastn.Model=Enti;fastn.base=function(type,settings,children){return new BaseComponent(fastn,type,settings,children)};for(var key in components){var componentConstructor=components[key];if(componentConstructor.expectedComponents){validateExpectedComponents(components,key,componentConstructor.expectedComponents)}}return fastn}},{"./baseComponent":1,"./binding":2,"./containerComponent":3,"./is":6,"./property":17,crel:7,enti:8,"object-assign":9}]},{},[]);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){function flatMerge(a,b){if(!b||typeof b!=="object"){b={}}if(!a||typeof a!=="object"){a=new b.constructor}var result=new a.constructor,aKeys=Object.keys(a),bKeys=Object.keys(b);for(var i=0;i<aKeys.length;i++){result[aKeys[i]]=a[aKeys[i]]}for(var i=0;i<bKeys.length;i++){result[bKeys[i]]=b[bKeys[i]]}return result}module.exports=flatMerge},{}],2:[function(require,module,exports){"use strict";function mapEach(map,operation){var keys=map.keys();var next;while(!(next=keys.next()).done){operation(map.get(next.value),next.value,map)}}var Multimap=function(){var mapCtor;if(typeof Map!=="undefined"){mapCtor=Map}function Multimap(iterable){var self=this;self._map=mapCtor;if(Multimap.Map){self._map=Multimap.Map}self._=self._map?new self._map:{};if(iterable){iterable.forEach(function(i){self.set(i[0],i[1])})}}Multimap.prototype.get=function(key){return this._map?this._.get(key):this._[key]};Multimap.prototype.set=function(key,val){var args=Array.prototype.slice.call(arguments);key=args.shift();var entry=this.get(key);if(!entry){entry=[];if(this._map)this._.set(key,entry);else this._[key]=entry}Array.prototype.push.apply(entry,args);return this};Multimap.prototype.delete=function(key,val){if(!this.has(key))return false;if(arguments.length==1){this._map?this._.delete(key):delete this._[key];return true}else{var entry=this.get(key);var idx=entry.indexOf(val);if(idx!=-1){entry.splice(idx,1);return true}}return false};Multimap.prototype.has=function(key,val){var hasKey=this._map?this._.has(key):this._.hasOwnProperty(key);if(arguments.length==1||!hasKey)return hasKey;var entry=this.get(key)||[];return entry.indexOf(val)!=-1};Multimap.prototype.keys=function(){if(this._map)return makeIterator(this._.keys());return makeIterator(Object.keys(this._))};Multimap.prototype.values=function(){var vals=[];this.forEachEntry(function(entry){Array.prototype.push.apply(vals,entry)});return makeIterator(vals)};Multimap.prototype.forEachEntry=function(iter){mapEach(this,iter)};Multimap.prototype.forEach=function(iter){var self=this;self.forEachEntry(function(entry,key){entry.forEach(function(item){iter(item,key,self)})})};Multimap.prototype.clear=function(){if(this._map){this._.clear()}else{this._={}}};Object.defineProperty(Multimap.prototype,"size",{configurable:false,enumerable:true,get:function(){var total=0;mapEach(this,function(value){total+=value.length});return total}});var safariNext;try{safariNext=new Function("iterator","makeIterator","var keysArray = []; for(var key of iterator){keysArray.push(key);} return makeIterator(keysArray).next;")}catch(error){}function makeIterator(iterator){if(Array.isArray(iterator)){var nextIndex=0;return{next:function(){return nextIndex<iterator.length?{value:iterator[nextIndex++],done:false}:{done:true}}}}if(!iterator.next&&safariNext){iterator.next=safariNext(iterator,makeIterator)}return iterator}return Multimap}();if(typeof exports==="object"&&module&&module.exports)module.exports=Multimap;else if(typeof define==="function"&&define.amd)define(function(){return Multimap})},{}],"fastn/listComponent":[function(require,module,exports){var MultiMap=require("multimap"),merge=require("flat-merge");MultiMap.Map=Map;function each(value,fn){if(!value||typeof value!=="object"){return}if(Array.isArray(value)){for(var i=0;i<value.length;i++){fn(value[i],i)}}else{for(var key in value){fn(value[key],key)}}}function keyFor(object,value){if(!object||typeof object!=="object"){return false}if(Array.isArray(object)){var index=object.indexOf(value);return index>=0?index:false}for(var key in object){if(object[key]===value){return key}}return false}module.exports=function(fastn,component,type,settings,children){if(fastn.components._generic){component.extend("_generic",settings,children)}else{component.extend("_container",settings,children)}var itemsMap=new MultiMap,dataMap=new WeakMap,lastTemplate,existingItem={};function updateItems(){var value=component.items(),template=component.template(),emptyTemplate=component.emptyTemplate(),newTemplate=lastTemplate!==template;var currentItems=merge(template?value:[]);itemsMap.forEach(function(childComponent,item){var currentKey=keyFor(currentItems,item);if(!newTemplate&&currentKey!==false){currentItems[currentKey]=[existingItem,item,childComponent]}else{removeComponent(childComponent);itemsMap.delete(item)}});var index=0;function updateItem(item,key){var child,existing;while(index<component._children.length&&!component._children[index]._templated){index++}if(Array.isArray(item)&&item[0]===existingItem){existing=true;child=item[2];item=item[1]}var childModel;if(!existing){childModel=new fastn.Model({item:item,key:key});child=fastn.toComponent(template(childModel,component.scope()));if(!child){child=fastn("template")}child._listItem=item;child._templated=true;dataMap.set(child,childModel);itemsMap.set(item,child)}else{childModel=dataMap.get(child);childModel.set("key",key)}if(fastn.isComponent(child)&&component._settings.attachTemplates!==false){child.attach(childModel,2)}component.insert(child,index);index++}each(currentItems,updateItem);lastTemplate=template;if(index===0&&emptyTemplate){var child=fastn.toComponent(emptyTemplate(component.scope()));if(!child){child=fastn("template")}child._templated=true;itemsMap.set({},child);component.insert(child)}}function removeComponent(childComponent){component.remove(childComponent);childComponent.destroy()}component.setProperty("items",fastn.property([],settings.itemChanges||"type keys shallowStructure").on("change",updateItems));component.setProperty("template",fastn.property().on("change",updateItems));component.setProperty("emptyTemplate",fastn.property().on("change",updateItems));return component}},{"flat-merge":1,multimap:2}]},{},[]);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}({"fastn/textComponent":[function(require,module,exports){function updateText(){if(!this.element){return}var value=this.text();this.element.textContent=value==null?"":value}function autoRender(content){this.element=document.createTextNode(content)}function autoText(text,fastn,content){text.render=autoRender.bind(text,content);return text}function render(){this.element=this.createTextNode(this.text());this.emit("render")}function textComponent(fastn,component,type,settings,children){if(settings.auto){delete settings.auto;if(!fastn.isBinding(children[0])){return autoText(component,fastn,children[0])}settings.text=children.pop()}component.createTextNode=textComponent.createTextNode;component.render=render.bind(component);component.setProperty("text",fastn.property("",updateText.bind(component)));return component}textComponent.createTextNode=function(text){return document.createTextNode(text)};module.exports=textComponent},{}]},{},[]);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}({"fastn/templaterComponent":[function(require,module,exports){module.exports=function(fastn,component,type,settings,children){var itemModel=new fastn.Model({});function replaceElement(element){if(component.element&&component.element.parentNode){component.element.parentNode.replaceChild(element,component.element)}component.element=element}function update(){var value=component.data(),template=component.template();itemModel.set("item",value);var newComponent=template&&fastn.toComponent(template(itemModel,component.scope(),component._currentComponent));if(component._currentComponent&&component._currentComponent!==newComponent){if(fastn.isComponent(component._currentComponent)){component._currentComponent.destroy()}}component._currentComponent=newComponent;if(!newComponent){replaceElement(component.emptyElement);return}if(fastn.isComponent(newComponent)){if(component._settings.attachTemplates!==false){newComponent.attach(itemModel,2)}else{newComponent.attach(component.scope(),1)}if(component.element&&component.element!==newComponent.element){if(newComponent.element==null){newComponent.render()}replaceElement(component._currentComponent.element)}}}component.render=function(){var element;component.emptyElement=document.createTextNode("");if(component._currentComponent){component._currentComponent.render();element=component._currentComponent.element}component.element=element||component.emptyElement;component.emit("render")};component.setProperty("data",fastn.property(undefined,settings.dataChanges||"value structure").on("change",update));component.setProperty("template",fastn.property(undefined,"value").on("change",update));component.on("destroy",function(){if(fastn.isComponent(component._currentComponent)){component._currentComponent.destroy()}});component.on("attach",function(data){if(fastn.isComponent(component._currentComponent)){component._currentComponent.attach(component.scope(),1)}});return component}},{}]},{},[]);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){function insertChild(fastn,container,child,index){var currentIndex=container._children.indexOf(child),newComponent=fastn.toComponent(child);if(newComponent!==child){container._children.splice(currentIndex,1,newComponent)}if(!~currentIndex||newComponent!==child){newComponent.attach(container.scope(),1)}if(currentIndex!==index){if(~currentIndex){container._children.splice(currentIndex,1)}container._children.splice(index,0,newComponent)}if(container.element){if(!newComponent.element){newComponent.render()}container._insert(newComponent.element,index);newComponent.emit("insert",container)}}function getContainerElement(){return this.containerElement||this.element}function insert(child,index){var childComponent=child,container=this.container,fastn=this.fastn;if(index&&typeof index==="object"){childComponent=Array.prototype.slice.call(arguments)}if(isNaN(index)){index=container._children.length}if(Array.isArray(childComponent)){for(var i=0;i<childComponent.length;i++){container.insert(childComponent[i],i+index)}}else{insertChild(fastn,container,childComponent,index)}return container}module.exports=function(fastn,component,type,settings,children){component.insert=insert.bind({container:component,fastn:fastn});component._insert=function(element,index){var containerElement=component.getContainerElement();if(!containerElement){return}if(containerElement.childNodes[index]===element){return}containerElement.insertBefore(element,containerElement.childNodes[index])};component.remove=function(childComponent){var index=component._children.indexOf(childComponent);if(~index){component._children.splice(index,1)}childComponent.detach(1);if(childComponent.element){component._remove(childComponent.element)}};component._remove=function(element){var containerElement=component.getContainerElement();if(!element||!containerElement||element.parentNode!==containerElement){return}containerElement.removeChild(element)};component.empty=function(){while(component._children.length){component.remove(component._children.pop())}};component.replaceChild=function(oldChild,newChild){var index=component._children.indexOf(oldChild);if(!~index){return}component.remove(oldChild);component.insert(newChild,index)};component.getContainerElement=getContainerElement.bind(component);component.on("render",component.insert.bind(null,component._children,0));component.on("attach",function(model,firm){for(var i=0;i<component._children.length;i++){if(fastn.isComponent(component._children[i])){component._children[i].attach(model,firm)}}});component.on("destroy",function(data,firm){for(var i=0;i<component._children.length;i++){if(fastn.isComponent(component._children[i])){component._children[i].destroy(firm)}}});return component}},{}],2:[function(require,module,exports){var setify=require("setify"),classist=require("classist");function updateTextProperty(generic,element,value){if(arguments.length===2){return element.textContent}element.textContent=value==null?"":value}module.exports={"class":function(generic,element,value){if(!generic._classist){generic._classist=classist(element)}if(arguments.length<3){return generic._classist()}generic._classist(value)},display:function(generic,element,value){if(arguments.length===2){return element.style.display!=="none"}element.style.display=value?null:"none"},disabled:function(generic,element,value){if(arguments.length===2){return element.hasAttribute("disabled")}if(value){element.setAttribute("disabled","disabled")}else{element.removeAttribute("disabled")}},textContent:updateTextProperty,innerText:updateTextProperty,innerHTML:updateTextProperty,value:function(generic,element,value){var inputType=element.type;if(element.nodeName==="INPUT"&&inputType==="date"){if(arguments.length===2){return element.value?new Date(element.value.replace(/-/g,"/").replace("T"," ")):null}value=value!=null?new Date(value):null;if(!value||isNaN(value)){element.value=null}else{element.value=[value.getFullYear(),("0"+(value.getMonth()+1)).slice(-2),("0"+value.getDate()).slice(-2)].join("-")}return}if(arguments.length===2){return element.value}if(value===undefined){value=null}if(element.nodeName==="PROGRESS"){value=parseFloat(value)||0}setify(element,value)},max:function(generic,element,value){if(arguments.length===2){return element.value}if(element.nodeName==="PROGRESS"){value=parseFloat(value)||0}element.max=value},style:function(generic,element,value){if(arguments.length===2){return element.style}for(var key in value){element.style[key]=value[key]}}}},{classist:3,setify:4}],3:[function(require,module,exports){module.exports=function(element){var lastClasses=[];return function(classes){if(!arguments.length){return lastClasses.join(" ")}function cleanClassName(result,className){if(typeof className==="string"&&className.match(/\s/)){className=className.split(" ")}if(Array.isArray(className)){return result.concat(className.reduce(cleanClassName,[]))}if(className!=null&&className!==""&&typeof className!=="boolean"){result.push(String(className).trim())}return result}var newClasses=cleanClassName([],classes),currentClasses=element.className?element.className.split(" "):[];lastClasses.map(function(className){if(!className){return}var index=currentClasses.indexOf(className);if(~index){currentClasses.splice(index,1)}});currentClasses=currentClasses.concat(newClasses);lastClasses=newClasses;element.className=currentClasses.join(" ")}}},{}],4:[function(require,module,exports){var naturalSelection=require("natural-selection");module.exports=function(element,value){var canSet=naturalSelection(element)&&element===document.activeElement;if(canSet){var start=element.selectionStart,end=element.selectionEnd;element.value=value;element.setSelectionRange(start,end)}else{element.value=value}}},{"natural-selection":5}],5:[function(require,module,exports){var supportedTypes=["text","search","tel","url","password"];module.exports=function(element){return!!(element.setSelectionRange&&~supportedTypes.indexOf(element.type))}},{}],6:[function(require,module,exports){var todo=[],todoKeys=[],scheduled,updates=0;function run(){var startTime=Date.now();while(todo.length&&Date.now()-startTime<16){todoKeys.shift();todo.shift()()}if(todo.length){requestAnimationFrame(run)}else{scheduled=false}}function schedule(key,fn){if(~todoKeys.indexOf(key)){return}todo.push(fn);todoKeys.push(key);if(!scheduled){scheduled=true;requestAnimationFrame(run)}}module.exports=schedule},{}],"fastn/genericComponent":[function(require,module,exports){var containerComponent=require("./containerComponent"),schedule=require("./schedule"),fancyProps=require("./fancyProps"),matchDomHandlerName=/^((?:el\.)?)([^. ]+)(?:\.(capture))?$/,GENERIC="_generic";function createProperties(fastn,component,settings){for(var key in settings){var setting=settings[key];if(typeof setting==="function"&&!fastn.isProperty(setting)&&!fastn.isBinding(setting)){continue}component.addDomProperty(key)}}function addDomHandler(component,element,handlerName,eventName,capture){var eventParts=handlerName.split(".");if(eventParts[0]==="on"){eventParts.shift()}var handler=function(event){component.emit(handlerName,event,component.scope())};element.addEventListener(eventName,handler,capture);component.on("destroy",function(){element.removeEventListener(eventName,handler,capture)})}function addDomHandlers(component,element,eventNames){var events=eventNames.split(" ");for(var i=0;i<events.length;i++){var eventName=events[i],match=eventName.match(matchDomHandlerName);if(!match){continue}if(match[1]||"on"+match[2]in element){addDomHandler(component,element,eventNames,match[2],match[3])}}}function addAutoHandler(component,element,key,settings){if(!settings[key]){return}var autoEvent=settings[key].split(":"),eventName=key.slice(2);delete settings[key];var handler=function(event){var fancyProp=fancyProps[autoEvent[1]],value=fancyProp?fancyProp(component,element):element[autoEvent[1]];component[autoEvent[0]](value)};element.addEventListener(eventName,handler);component.on("destroy",function(){element.removeEventListener(eventName,handler)})}function addDomProperty(fastn,key,property){var component=this;property=property||component[key]||fastn.property();component.setProperty(key,property);function update(){var element=component.getPropertyElement(key),value=property();if(!element||component.destroyed()){return}var isProperty=key in element,fancyProp=fancyProps[key],previous=fancyProp?fancyProp(component,element):isProperty?element[key]:element.getAttribute(key);if(!fancyProp&&!isProperty&&value==null){value=""}if(value!==previous){if(fancyProp){fancyProp(component,element,value);return}if(isProperty){element[key]=value;return}if(typeof value!=="function"&&typeof value!=="object"){element.setAttribute(key,value)}}}property.updater(update)}function onRender(){var component=this,element;for(var key in component._settings){element=component.getEventElement(key);if(key.slice(0,2)==="on"&&key in element){addAutoHandler(component,element,key,component._settings)}}for(var eventKey in component._events){element=component.getEventElement(key);addDomHandlers(component,element,eventKey)}}function render(){this.element=this.createElement(this._settings.tagName||this._tagName);this.emit("render");return this}function genericComponent(fastn,component,type,settings,children){if(component.is(type)){return component}if(type===GENERIC){component._tagName=component._tagName||"div"}else{component._tagName=type}if(component.is(GENERIC)){return component}component.extend("_container",settings,children);component.addDomProperty=addDomProperty.bind(component,fastn);component.getEventElement=component.getContainerElement;component.getPropertyElement=component.getContainerElement;component.updateProperty=genericComponent.updateProperty;component.createElement=genericComponent.createElement;createProperties(fastn,component,settings);component.render=render.bind(component);component.on("render",onRender);return component}genericComponent.updateProperty=function(component,property,update){if(typeof document!=="undefined"&&document.contains(component.element)){schedule(property,update)}else{update()}};genericComponent.createElement=function(tagName){if(tagName instanceof Node){return tagName}return document.createElement(tagName)};module.exports=genericComponent},{"./containerComponent":1,"./fancyProps":2,"./schedule":6}]},{},[]);var fastn=require("fastn")({list:require("fastn/listComponent"),text:require("fastn/textComponent"),templater:require("fastn/templaterComponent"),_generic:require("fastn/genericComponent")},true);var app=fastn("div",fastn("button",{"class":"mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"},fastn("i",{"class":"material-icons"},"airplay")),fastn("button",{"class":"mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"},fastn("i",{"class":"material-icons"},"android")),fastn("button",{"class":"mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"},fastn("i",{"class":"material-icons"},"save")),fastn("button",{"class":"mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect"},fastn("i",{"class":"material-icons"},"battery_charging_full")));app.render();document.body.appendChild(app.element);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"fastn": "2.5.1"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.1.0/material.min.js"></script>
<style>
body{
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
}
.mdl-button {
margin: 8px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment