made with requirebin
Created
July 4, 2015 20:42
-
-
Save ichabodcole/74b441da97ef7332ec32 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
'use strict'; | |
//var global = require('global'); | |
//var document = require('global/document'); | |
var immstruct = require('immstruct'); | |
var hg = require('mercury'); | |
var h = hg.h; | |
var ctx = new AudioContext(); | |
var masterGain = ctx.createGain(); | |
masterGain.connect(ctx.destination); | |
var osc = ctx.createOscillator(); | |
var structure = immstruct('modules', [ | |
{ | |
id: 1, | |
volume: 0.5, | |
frequency: 220, | |
waveType: 'sine', | |
}, | |
{ | |
id: 2, | |
volume: 0.45, | |
frequency: 100, | |
waveType: 'triangle' | |
} | |
]); | |
initSounds(structure); | |
function initSounds(data) { | |
console.log(data); | |
data.modules | |
.forEach(function(module, index, array) { | |
var gain = ctx.createGain(); | |
var osc = ctx.createOscillator(); | |
gain.gain.value = module.volume; | |
osc.frequency.value = module.frequency; | |
osc.type = module.waveType; | |
osc.connect(gain); | |
gain.connect(masterGain); | |
osc.start(); | |
}); | |
} | |
function setPitch(state) { | |
} | |
function App() { | |
return hg.state({ | |
pitch: hg.value(150), | |
channels: { | |
updates: setPitch | |
} | |
}); | |
} | |
function incrementCounter(state) { | |
state.value.set(state.value() + 1); | |
} | |
App.render = function(state) { | |
return h('div.counter', [ | |
'The state ' | |
, h('code', 'clickCount') | |
, (' has value: ' + state.pitch + '.') | |
, h('input.button', { | |
type: 'button', | |
value: 'click me', | |
'ev-click': hg.send(state.channels.updates) | |
}) | |
]); | |
}; | |
hg.app(document.body, App(), App.render); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){"use strict";function EE(fn,context,once){this.fn=fn;this.context=context;this.once=once||false}function EventEmitter(){}EventEmitter.prototype._events=undefined;EventEmitter.prototype.listeners=function listeners(event){if(!this._events||!this._events[event])return[];if(this._events[event].fn)return[this._events[event].fn];for(var i=0,l=this._events[event].length,ee=new Array(l);i<l;i++){ee[i]=this._events[event][i].fn}return ee};EventEmitter.prototype.emit=function emit(event,a1,a2,a3,a4,a5){if(!this._events||!this._events[event])return false;var listeners=this._events[event],len=arguments.length,args,i;if("function"===typeof listeners.fn){if(listeners.once)this.removeListener(event,listeners.fn,true);switch(len){case 1:return listeners.fn.call(listeners.context),true;case 2:return listeners.fn.call(listeners.context,a1),true;case 3:return listeners.fn.call(listeners.context,a1,a2),true;case 4:return listeners.fn.call(listeners.context,a1,a2,a3),true;case 5:return listeners.fn.call(listeners.context,a1,a2,a3,a4),true;case 6:return listeners.fn.call(listeners.context,a1,a2,a3,a4,a5),true}for(i=1,args=new Array(len-1);i<len;i++){args[i-1]=arguments[i]}listeners.fn.apply(listeners.context,args)}else{var length=listeners.length,j;for(i=0;i<length;i++){if(listeners[i].once)this.removeListener(event,listeners[i].fn,true);switch(len){case 1:listeners[i].fn.call(listeners[i].context);break;case 2:listeners[i].fn.call(listeners[i].context,a1);break;case 3:listeners[i].fn.call(listeners[i].context,a1,a2);break;default:if(!args)for(j=1,args=new Array(len-1);j<len;j++){args[j-1]=arguments[j]}listeners[i].fn.apply(listeners[i].context,args)}}}return true};EventEmitter.prototype.on=function on(event,fn,context){var listener=new EE(fn,context||this);if(!this._events)this._events={};if(!this._events[event])this._events[event]=listener;else{if(!this._events[event].fn)this._events[event].push(listener);else this._events[event]=[this._events[event],listener]}return this};EventEmitter.prototype.once=function once(event,fn,context){var listener=new EE(fn,context||this,true);if(!this._events)this._events={};if(!this._events[event])this._events[event]=listener;else{if(!this._events[event].fn)this._events[event].push(listener);else this._events[event]=[this._events[event],listener]}return this};EventEmitter.prototype.removeListener=function removeListener(event,fn,once){if(!this._events||!this._events[event])return this;var listeners=this._events[event],events=[];if(fn){if(listeners.fn&&(listeners.fn!==fn||once&&!listeners.once)){events.push(listeners)}if(!listeners.fn)for(var i=0,length=listeners.length;i<length;i++){if(listeners[i].fn!==fn||once&&!listeners[i].once){events.push(listeners[i])}}}if(events.length){this._events[event]=events.length===1?events[0]:events}else{delete this._events[event]}return this};EventEmitter.prototype.removeAllListeners=function removeAllListeners(event){if(!this._events)return this;if(event)delete this._events[event];else this._events={};return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.addListener=EventEmitter.prototype.on;EventEmitter.prototype.setMaxListeners=function setMaxListeners(){return this};EventEmitter.EventEmitter=EventEmitter;EventEmitter.EventEmitter2=EventEmitter;EventEmitter.EventEmitter3=EventEmitter;module.exports=EventEmitter},{}],2:[function(require,module,exports){var Immutable=require("immutable");var Iterable=Immutable.Iterable;var Iterator=Iterable.Iterator;var Seq=Immutable.Seq;var Map=Immutable.Map;var Record=Immutable.Record;function cursorFrom(rootData,keyPath,onChange){if(arguments.length===1){keyPath=[]}else if(typeof keyPath==="function"){onChange=keyPath;keyPath=[]}else{keyPath=valToKeyPath(keyPath)}return makeCursor(rootData,keyPath,onChange)}var KeyedCursorPrototype=Object.create(Seq.Keyed.prototype);var IndexedCursorPrototype=Object.create(Seq.Indexed.prototype);function KeyedCursor(rootData,keyPath,onChange,size){this.size=size;this._rootData=rootData;this._keyPath=keyPath;this._onChange=onChange}KeyedCursorPrototype.constructor=KeyedCursor;function IndexedCursor(rootData,keyPath,onChange,size){this.size=size;this._rootData=rootData;this._keyPath=keyPath;this._onChange=onChange}IndexedCursorPrototype.constructor=IndexedCursor;KeyedCursorPrototype.toString=function(){return this.__toString("Cursor {","}")};IndexedCursorPrototype.toString=function(){return this.__toString("Cursor [","]")};KeyedCursorPrototype.deref=KeyedCursorPrototype.valueOf=IndexedCursorPrototype.deref=IndexedCursorPrototype.valueOf=function(notSetValue){return this._rootData.getIn(this._keyPath,notSetValue)};KeyedCursorPrototype.get=IndexedCursorPrototype.get=function(key,notSetValue){return this.getIn([key],notSetValue)};KeyedCursorPrototype.getIn=IndexedCursorPrototype.getIn=function(keyPath,notSetValue){keyPath=listToKeyPath(keyPath);if(keyPath.length===0){return this}var value=this._rootData.getIn(newKeyPath(this._keyPath,keyPath),NOT_SET);return value===NOT_SET?notSetValue:wrappedValue(this,keyPath,value)};IndexedCursorPrototype.set=KeyedCursorPrototype.set=function(key,value){return updateCursor(this,function(m){return m.set(key,value)},[key])};IndexedCursorPrototype.push=function(){var args=arguments;return updateCursor(this,function(m){return m.push.apply(m,args)})};IndexedCursorPrototype.pop=function(){return updateCursor(this,function(m){return m.pop()})};IndexedCursorPrototype.unshift=function(){var args=arguments;return updateCursor(this,function(m){return m.unshift.apply(m,args)})};IndexedCursorPrototype.shift=function(){return updateCursor(this,function(m){return m.shift()})};IndexedCursorPrototype.setIn=KeyedCursorPrototype.setIn=Map.prototype.setIn;KeyedCursorPrototype.remove=KeyedCursorPrototype["delete"]=IndexedCursorPrototype.remove=IndexedCursorPrototype["delete"]=function(key){return updateCursor(this,function(m){return m.remove(key)},[key])};IndexedCursorPrototype.removeIn=IndexedCursorPrototype.deleteIn=KeyedCursorPrototype.removeIn=KeyedCursorPrototype.deleteIn=Map.prototype.deleteIn;KeyedCursorPrototype.clear=IndexedCursorPrototype.clear=function(){return updateCursor(this,function(m){return m.clear()})};IndexedCursorPrototype.update=KeyedCursorPrototype.update=function(keyOrFn,notSetValue,updater){return arguments.length===1?updateCursor(this,keyOrFn):this.updateIn([keyOrFn],notSetValue,updater)};IndexedCursorPrototype.updateIn=KeyedCursorPrototype.updateIn=function(keyPath,notSetValue,updater){return updateCursor(this,function(m){return m.updateIn(keyPath,notSetValue,updater)},keyPath)};IndexedCursorPrototype.merge=KeyedCursorPrototype.merge=function(){var args=arguments;return updateCursor(this,function(m){return m.merge.apply(m,args)})};IndexedCursorPrototype.mergeWith=KeyedCursorPrototype.mergeWith=function(merger){var args=arguments;return updateCursor(this,function(m){return m.mergeWith.apply(m,args)})};IndexedCursorPrototype.mergeIn=KeyedCursorPrototype.mergeIn=Map.prototype.mergeIn;IndexedCursorPrototype.mergeDeep=KeyedCursorPrototype.mergeDeep=function(){var args=arguments;return updateCursor(this,function(m){return m.mergeDeep.apply(m,args)})};IndexedCursorPrototype.mergeDeepWith=KeyedCursorPrototype.mergeDeepWith=function(merger){var args=arguments;return updateCursor(this,function(m){return m.mergeDeepWith.apply(m,args)})};IndexedCursorPrototype.mergeDeepIn=KeyedCursorPrototype.mergeDeepIn=Map.prototype.mergeDeepIn;KeyedCursorPrototype.withMutations=IndexedCursorPrototype.withMutations=function(fn){return updateCursor(this,function(m){return(m||Map()).withMutations(fn)})};KeyedCursorPrototype.cursor=IndexedCursorPrototype.cursor=function(subKeyPath){subKeyPath=valToKeyPath(subKeyPath);return subKeyPath.length===0?this:subCursor(this,subKeyPath)};KeyedCursorPrototype.__iterate=IndexedCursorPrototype.__iterate=function(fn,reverse){var cursor=this;var deref=cursor.deref();return deref&&deref.__iterate?deref.__iterate(function(v,k){return fn(wrappedValue(cursor,[k],v),k,cursor)},reverse):0};KeyedCursorPrototype.__iterator=IndexedCursorPrototype.__iterator=function(type,reverse){var deref=this.deref();var cursor=this;var iterator=deref&&deref.__iterator&&deref.__iterator(Iterator.ENTRIES,reverse);return new Iterator(function(){if(!iterator){return{value:undefined,done:true}}var step=iterator.next();if(step.done){return step}var entry=step.value;var k=entry[0];var v=wrappedValue(cursor,[k],entry[1]);return{value:type===Iterator.KEYS?k:type===Iterator.VALUES?v:[k,v],done:false}})};KeyedCursor.prototype=KeyedCursorPrototype;IndexedCursor.prototype=IndexedCursorPrototype;var NOT_SET={};function makeCursor(rootData,keyPath,onChange,value){if(arguments.length<4){value=rootData.getIn(keyPath)}var size=value&&value.size;var CursorClass=Iterable.isIndexed(value)?IndexedCursor:KeyedCursor;var cursor=new CursorClass(rootData,keyPath,onChange,size);if(value instanceof Record){defineRecordProperties(cursor,value)}return cursor}function defineRecordProperties(cursor,value){try{value._keys.forEach(setProp.bind(undefined,cursor))}catch(error){}}function setProp(prototype,name){Object.defineProperty(prototype,name,{get:function(){return this.get(name)},set:function(value){if(!this.__ownerID){throw new Error("Cannot set on an immutable record.")}}})}function wrappedValue(cursor,keyPath,value){return Iterable.isIterable(value)?subCursor(cursor,keyPath,value):value}function subCursor(cursor,keyPath,value){if(arguments.length<3){return makeCursor(cursor._rootData,newKeyPath(cursor._keyPath,keyPath),cursor._onChange)}return makeCursor(cursor._rootData,newKeyPath(cursor._keyPath,keyPath),cursor._onChange,value)}function updateCursor(cursor,changeFn,changeKeyPath){var deepChange=arguments.length>2;var newRootData=cursor._rootData.updateIn(cursor._keyPath,deepChange?Map():undefined,changeFn);var keyPath=cursor._keyPath||[];var result=cursor._onChange&&cursor._onChange.call(undefined,newRootData,cursor._rootData,deepChange?newKeyPath(keyPath,changeKeyPath):keyPath);if(result!==undefined){newRootData=result}return makeCursor(newRootData,cursor._keyPath,cursor._onChange)}function newKeyPath(head,tail){return head.concat(listToKeyPath(tail))}function listToKeyPath(list){return Array.isArray(list)?list:Immutable.Iterable(list).toArray()}function valToKeyPath(val){return Array.isArray(val)?val:Iterable.isIterable(val)?val.toArray():[val]}exports.from=cursorFrom},{immutable:3}],3:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.Immutable=factory()})(this,function(){"use strict";var SLICE$0=Array.prototype.slice;function createClass(ctor,superClass){if(superClass){ctor.prototype=Object.create(superClass.prototype)}ctor.prototype.constructor=ctor}var DELETE="delete";var SHIFT=5;var SIZE=1<<SHIFT;var MASK=SIZE-1;var NOT_SET={};var CHANGE_LENGTH={value:false};var DID_ALTER={value:false};function MakeRef(ref){ref.value=false;return ref}function SetRef(ref){ref&&(ref.value=true)}function OwnerID(){}function arrCopy(arr,offset){offset=offset||0;var len=Math.max(0,arr.length-offset);var newArr=new Array(len);for(var ii=0;ii<len;ii++){newArr[ii]=arr[ii+offset]}return newArr}function ensureSize(iter){if(iter.size===undefined){iter.size=iter.__iterate(returnTrue)}return iter.size}function wrapIndex(iter,index){return index>=0?+index:ensureSize(iter)+ +index}function returnTrue(){return true}function wholeSlice(begin,end,size){return(begin===0||size!==undefined&&begin<=-size)&&(end===undefined||size!==undefined&&end>=size)}function resolveBegin(begin,size){return resolveIndex(begin,size,0)}function resolveEnd(end,size){return resolveIndex(end,size,size)}function resolveIndex(index,size,defaultIndex){return index===undefined?defaultIndex:index<0?Math.max(0,size+index):size===undefined?index:Math.min(size,index)}function Iterable(value){return isIterable(value)?value:Seq(value)}createClass(KeyedIterable,Iterable);function KeyedIterable(value){return isKeyed(value)?value:KeyedSeq(value)}createClass(IndexedIterable,Iterable);function IndexedIterable(value){return isIndexed(value)?value:IndexedSeq(value)}createClass(SetIterable,Iterable);function SetIterable(value){return isIterable(value)&&!isAssociative(value)?value:SetSeq(value)}function isIterable(maybeIterable){return!!(maybeIterable&&maybeIterable[IS_ITERABLE_SENTINEL])}function isKeyed(maybeKeyed){return!!(maybeKeyed&&maybeKeyed[IS_KEYED_SENTINEL])}function isIndexed(maybeIndexed){return!!(maybeIndexed&&maybeIndexed[IS_INDEXED_SENTINEL])}function isAssociative(maybeAssociative){return isKeyed(maybeAssociative)||isIndexed(maybeAssociative)}function isOrdered(maybeOrdered){return!!(maybeOrdered&&maybeOrdered[IS_ORDERED_SENTINEL])}Iterable.isIterable=isIterable;Iterable.isKeyed=isKeyed;Iterable.isIndexed=isIndexed;Iterable.isAssociative=isAssociative;Iterable.isOrdered=isOrdered;Iterable.Keyed=KeyedIterable;Iterable.Indexed=IndexedIterable;Iterable.Set=SetIterable;var IS_ITERABLE_SENTINEL="@@__IMMUTABLE_ITERABLE__@@";var IS_KEYED_SENTINEL="@@__IMMUTABLE_KEYED__@@";var IS_INDEXED_SENTINEL="@@__IMMUTABLE_INDEXED__@@";var IS_ORDERED_SENTINEL="@@__IMMUTABLE_ORDERED__@@";var ITERATE_KEYS=0;var ITERATE_VALUES=1;var ITERATE_ENTRIES=2;var REAL_ITERATOR_SYMBOL=typeof Symbol==="function"&&Symbol.iterator;var FAUX_ITERATOR_SYMBOL="@@iterator";var ITERATOR_SYMBOL=REAL_ITERATOR_SYMBOL||FAUX_ITERATOR_SYMBOL;function src_Iterator__Iterator(next){this.next=next}src_Iterator__Iterator.prototype.toString=function(){return"[Iterator]"};src_Iterator__Iterator.KEYS=ITERATE_KEYS;src_Iterator__Iterator.VALUES=ITERATE_VALUES;src_Iterator__Iterator.ENTRIES=ITERATE_ENTRIES;src_Iterator__Iterator.prototype.inspect=src_Iterator__Iterator.prototype.toSource=function(){return this.toString()};src_Iterator__Iterator.prototype[ITERATOR_SYMBOL]=function(){return this};function iteratorValue(type,k,v,iteratorResult){var value=type===0?k:type===1?v:[k,v];iteratorResult?iteratorResult.value=value:iteratorResult={value:value,done:false};return iteratorResult}function iteratorDone(){return{value:undefined,done:true}}function hasIterator(maybeIterable){return!!getIteratorFn(maybeIterable)}function isIterator(maybeIterator){return maybeIterator&&typeof maybeIterator.next==="function"}function getIterator(iterable){var iteratorFn=getIteratorFn(iterable);return iteratorFn&&iteratorFn.call(iterable)}function getIteratorFn(iterable){var iteratorFn=iterable&&(REAL_ITERATOR_SYMBOL&&iterable[REAL_ITERATOR_SYMBOL]||iterable[FAUX_ITERATOR_SYMBOL]);if(typeof iteratorFn==="function"){return iteratorFn}}function isArrayLike(value){return value&&typeof value.length==="number"}createClass(Seq,Iterable);function Seq(value){return value===null||value===undefined?emptySequence():isIterable(value)?value.toSeq():seqFromValue(value)}Seq.of=function(){return Seq(arguments)};Seq.prototype.toSeq=function(){return this};Seq.prototype.toString=function(){return this.__toString("Seq {","}")};Seq.prototype.cacheResult=function(){if(!this._cache&&this.__iterateUncached){this._cache=this.entrySeq().toArray();this.size=this._cache.length}return this};Seq.prototype.__iterate=function(fn,reverse){return seqIterate(this,fn,reverse,true)};Seq.prototype.__iterator=function(type,reverse){return seqIterator(this,type,reverse,true)};createClass(KeyedSeq,Seq);function KeyedSeq(value){return value===null||value===undefined?emptySequence().toKeyedSeq():isIterable(value)?isKeyed(value)?value.toSeq():value.fromEntrySeq():keyedSeqFromValue(value)}KeyedSeq.prototype.toKeyedSeq=function(){return this};createClass(IndexedSeq,Seq);function IndexedSeq(value){return value===null||value===undefined?emptySequence():!isIterable(value)?indexedSeqFromValue(value):isKeyed(value)?value.entrySeq():value.toIndexedSeq()}IndexedSeq.of=function(){return IndexedSeq(arguments)};IndexedSeq.prototype.toIndexedSeq=function(){return this};IndexedSeq.prototype.toString=function(){return this.__toString("Seq [","]")};IndexedSeq.prototype.__iterate=function(fn,reverse){return seqIterate(this,fn,reverse,false)};IndexedSeq.prototype.__iterator=function(type,reverse){return seqIterator(this,type,reverse,false)};createClass(SetSeq,Seq);function SetSeq(value){return(value===null||value===undefined?emptySequence():!isIterable(value)?indexedSeqFromValue(value):isKeyed(value)?value.entrySeq():value).toSetSeq()}SetSeq.of=function(){return SetSeq(arguments)};SetSeq.prototype.toSetSeq=function(){return this};Seq.isSeq=isSeq;Seq.Keyed=KeyedSeq;Seq.Set=SetSeq;Seq.Indexed=IndexedSeq;var IS_SEQ_SENTINEL="@@__IMMUTABLE_SEQ__@@";Seq.prototype[IS_SEQ_SENTINEL]=true;createClass(ArraySeq,IndexedSeq);function ArraySeq(array){this._array=array;this.size=array.length}ArraySeq.prototype.get=function(index,notSetValue){return this.has(index)?this._array[wrapIndex(this,index)]:notSetValue};ArraySeq.prototype.__iterate=function(fn,reverse){var array=this._array;var maxIndex=array.length-1;for(var ii=0;ii<=maxIndex;ii++){if(fn(array[reverse?maxIndex-ii:ii],ii,this)===false){return ii+1}}return ii};ArraySeq.prototype.__iterator=function(type,reverse){var array=this._array;var maxIndex=array.length-1;var ii=0;return new src_Iterator__Iterator(function(){return ii>maxIndex?iteratorDone():iteratorValue(type,ii,array[reverse?maxIndex-ii++:ii++])})};createClass(ObjectSeq,KeyedSeq);function ObjectSeq(object){var keys=Object.keys(object);this._object=object;this._keys=keys;this.size=keys.length}ObjectSeq.prototype.get=function(key,notSetValue){if(notSetValue!==undefined&&!this.has(key)){return notSetValue}return this._object[key]};ObjectSeq.prototype.has=function(key){return this._object.hasOwnProperty(key)};ObjectSeq.prototype.__iterate=function(fn,reverse){var object=this._object;var keys=this._keys;var maxIndex=keys.length-1;for(var ii=0;ii<=maxIndex;ii++){var key=keys[reverse?maxIndex-ii:ii];if(fn(object[key],key,this)===false){return ii+1}}return ii};ObjectSeq.prototype.__iterator=function(type,reverse){var object=this._object;var keys=this._keys;var maxIndex=keys.length-1;var ii=0;return new src_Iterator__Iterator(function(){var key=keys[reverse?maxIndex-ii:ii];return ii++>maxIndex?iteratorDone():iteratorValue(type,key,object[key])})};ObjectSeq.prototype[IS_ORDERED_SENTINEL]=true;createClass(IterableSeq,IndexedSeq);function IterableSeq(iterable){this._iterable=iterable;this.size=iterable.length||iterable.size}IterableSeq.prototype.__iterateUncached=function(fn,reverse){if(reverse){return this.cacheResult().__iterate(fn,reverse)}var iterable=this._iterable;var iterator=getIterator(iterable);var iterations=0;if(isIterator(iterator)){var step;while(!(step=iterator.next()).done){if(fn(step.value,iterations++,this)===false){break}}}return iterations};IterableSeq.prototype.__iteratorUncached=function(type,reverse){if(reverse){return this.cacheResult().__iterator(type,reverse)}var iterable=this._iterable;var iterator=getIterator(iterable);if(!isIterator(iterator)){return new src_Iterator__Iterator(iteratorDone)}var iterations=0;return new src_Iterator__Iterator(function(){var step=iterator.next();return step.done?step:iteratorValue(type,iterations++,step.value)})};createClass(IteratorSeq,IndexedSeq);function IteratorSeq(iterator){this._iterator=iterator;this._iteratorCache=[]}IteratorSeq.prototype.__iterateUncached=function(fn,reverse){if(reverse){return this.cacheResult().__iterate(fn,reverse)}var iterator=this._iterator;var cache=this._iteratorCache;var iterations=0;while(iterations<cache.length){if(fn(cache[iterations],iterations++,this)===false){return iterations}}var step;while(!(step=iterator.next()).done){var val=step.value;cache[iterations]=val;if(fn(val,iterations++,this)===false){break}}return iterations};IteratorSeq.prototype.__iteratorUncached=function(type,reverse){if(reverse){return this.cacheResult().__iterator(type,reverse)}var iterator=this._iterator;var cache=this._iteratorCache;var iterations=0;return new src_Iterator__Iterator(function(){if(iterations>=cache.length){var step=iterator.next();if(step.done){return step}cache[iterations]=step.value}return iteratorValue(type,iterations,cache[iterations++])})};function isSeq(maybeSeq){return!!(maybeSeq&&maybeSeq[IS_SEQ_SENTINEL])}var EMPTY_SEQ;function emptySequence(){return EMPTY_SEQ||(EMPTY_SEQ=new ArraySeq([]))}function keyedSeqFromValue(value){var seq=Array.isArray(value)?new ArraySeq(value).fromEntrySeq():isIterator(value)?new IteratorSeq(value).fromEntrySeq():hasIterator(value)?new IterableSeq(value).fromEntrySeq():typeof value==="object"?new ObjectSeq(value):undefined;if(!seq){throw new TypeError("Expected Array or iterable object of [k, v] entries, "+"or keyed object: "+value)}return seq}function indexedSeqFromValue(value){var seq=maybeIndexedSeqFromValue(value);if(!seq){throw new TypeError("Expected Array or iterable object of values: "+value)}return seq}function seqFromValue(value){var seq=maybeIndexedSeqFromValue(value)||typeof value==="object"&&new ObjectSeq(value);if(!seq){throw new TypeError("Expected Array or iterable object of values, or keyed object: "+value)}return seq}function maybeIndexedSeqFromValue(value){return isArrayLike(value)?new ArraySeq(value):isIterator(value)?new IteratorSeq(value):hasIterator(value)?new IterableSeq(value):undefined}function seqIterate(seq,fn,reverse,useKeys){var cache=seq._cache;if(cache){var maxIndex=cache.length-1;for(var ii=0;ii<=maxIndex;ii++){var entry=cache[reverse?maxIndex-ii:ii];if(fn(entry[1],useKeys?entry[0]:ii,seq)===false){return ii+1}}return ii}return seq.__iterateUncached(fn,reverse)}function seqIterator(seq,type,reverse,useKeys){var cache=seq._cache;if(cache){var maxIndex=cache.length-1;var ii=0;return new src_Iterator__Iterator(function(){var entry=cache[reverse?maxIndex-ii:ii];return ii++>maxIndex?iteratorDone():iteratorValue(type,useKeys?entry[0]:ii-1,entry[1])})}return seq.__iteratorUncached(type,reverse)}createClass(Collection,Iterable);function Collection(){throw TypeError("Abstract")}createClass(KeyedCollection,Collection);function KeyedCollection(){}createClass(IndexedCollection,Collection);function IndexedCollection(){}createClass(SetCollection,Collection);function SetCollection(){}Collection.Keyed=KeyedCollection;Collection.Indexed=IndexedCollection;Collection.Set=SetCollection;function is(valueA,valueB){if(valueA===valueB||valueA!==valueA&&valueB!==valueB){return true}if(!valueA||!valueB){return false}if(typeof valueA.valueOf==="function"&&typeof valueB.valueOf==="function"){valueA=valueA.valueOf();valueB=valueB.valueOf();if(valueA===valueB||valueA!==valueA&&valueB!==valueB){return true}if(!valueA||!valueB){return false}}if(typeof valueA.equals==="function"&&typeof valueB.equals==="function"&&valueA.equals(valueB)){return true}return false}function fromJS(json,converter){return converter?fromJSWith(converter,json,"",{"":json}):fromJSDefault(json)}function fromJSWith(converter,json,key,parentJSON){if(Array.isArray(json)){return converter.call(parentJSON,key,IndexedSeq(json).map(function(v,k){return fromJSWith(converter,v,k,json)}))}if(isPlainObj(json)){return converter.call(parentJSON,key,KeyedSeq(json).map(function(v,k){return fromJSWith(converter,v,k,json)}))}return json}function fromJSDefault(json){if(Array.isArray(json)){return IndexedSeq(json).map(fromJSDefault).toList()}if(isPlainObj(json)){return KeyedSeq(json).map(fromJSDefault).toMap()}return json}function isPlainObj(value){return value&&(value.constructor===Object||value.constructor===undefined)}var src_Math__imul=typeof Math.imul==="function"&&Math.imul(4294967295,2)===-2?Math.imul:function src_Math__imul(a,b){a=a|0;b=b|0;var c=a&65535;var d=b&65535;return c*d+((a>>>16)*d+c*(b>>>16)<<16>>>0)|0};function smi(i32){return i32>>>1&1073741824|i32&3221225471}function hash(o){if(o===false||o===null||o===undefined){return 0}if(typeof o.valueOf==="function"){o=o.valueOf();if(o===false||o===null||o===undefined){return 0}}if(o===true){return 1}var type=typeof o;if(type==="number"){var h=o|0;if(h!==o){h^=o*4294967295}while(o>4294967295){o/=4294967295;h^=o}return smi(h)}if(type==="string"){return o.length>STRING_HASH_CACHE_MIN_STRLEN?cachedHashString(o):hashString(o)}if(typeof o.hashCode==="function"){return o.hashCode()}return hashJSObj(o)}function cachedHashString(string){var hash=stringHashCache[string];if(hash===undefined){hash=hashString(string);if(STRING_HASH_CACHE_SIZE===STRING_HASH_CACHE_MAX_SIZE){STRING_HASH_CACHE_SIZE=0;stringHashCache={}}STRING_HASH_CACHE_SIZE++;stringHashCache[string]=hash}return hash}function hashString(string){var hash=0;for(var ii=0;ii<string.length;ii++){hash=31*hash+string.charCodeAt(ii)|0}return smi(hash)}function hashJSObj(obj){var hash;if(usingWeakMap){hash=weakMap.get(obj);if(hash!==undefined){return hash}}hash=obj[UID_HASH_KEY];if(hash!==undefined){return hash}if(!canDefineProperty){hash=obj.propertyIsEnumerable&&obj.propertyIsEnumerable[UID_HASH_KEY];if(hash!==undefined){return hash}hash=getIENodeHash(obj);if(hash!==undefined){return hash}}hash=++objHashUID;if(objHashUID&1073741824){objHashUID=0}if(usingWeakMap){weakMap.set(obj,hash)}else if(isExtensible!==undefined&&isExtensible(obj)===false){throw new Error("Non-extensible objects are not allowed as keys.")}else if(canDefineProperty){Object.defineProperty(obj,UID_HASH_KEY,{enumerable:false,configurable:false,writable:false,value:hash})}else if(obj.propertyIsEnumerable!==undefined&&obj.propertyIsEnumerable===obj.constructor.prototype.propertyIsEnumerable){obj.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)};obj.propertyIsEnumerable[UID_HASH_KEY]=hash}else if(obj.nodeType!==undefined){obj[UID_HASH_KEY]=hash}else{throw new Error("Unable to set a non-enumerable property on object.")}return hash}var isExtensible=Object.isExtensible;var canDefineProperty=function(){try{Object.defineProperty({},"@",{});return true}catch(e){return false}}();function getIENodeHash(node){if(node&&node.nodeType>0){switch(node.nodeType){case 1:return node.uniqueID;case 9:return node.documentElement&&node.documentElement.uniqueID}}}var usingWeakMap=typeof WeakMap==="function";var weakMap;if(usingWeakMap){weakMap=new WeakMap}var objHashUID=0;var UID_HASH_KEY="__immutablehash__";if(typeof Symbol==="function"){UID_HASH_KEY=Symbol(UID_HASH_KEY)}var STRING_HASH_CACHE_MIN_STRLEN=16;var STRING_HASH_CACHE_MAX_SIZE=255;var STRING_HASH_CACHE_SIZE=0;var stringHashCache={};function invariant(condition,error){if(!condition)throw new Error(error)}function assertNotInfinite(size){invariant(size!==Infinity,"Cannot perform this action with an infinite size.")}createClass(ToKeyedSequence,KeyedSeq);function ToKeyedSequence(indexed,useKeys){this._iter=indexed;this._useKeys=useKeys;this.size=indexed.size}ToKeyedSequence.prototype.get=function(key,notSetValue){return this._iter.get(key,notSetValue)};ToKeyedSequence.prototype.has=function(key){return this._iter.has(key)};ToKeyedSequence.prototype.valueSeq=function(){return this._iter.valueSeq()};ToKeyedSequence.prototype.reverse=function(){var this$0=this;var reversedSequence=reverseFactory(this,true);if(!this._useKeys){reversedSequence.valueSeq=function(){return this$0._iter.toSeq().reverse()}}return reversedSequence};ToKeyedSequence.prototype.map=function(mapper,context){var this$0=this;var mappedSequence=mapFactory(this,mapper,context);if(!this._useKeys){mappedSequence.valueSeq=function(){return this$0._iter.toSeq().map(mapper,context)}}return mappedSequence};ToKeyedSequence.prototype.__iterate=function(fn,reverse){var this$0=this;var ii;return this._iter.__iterate(this._useKeys?function(v,k){return fn(v,k,this$0)}:(ii=reverse?resolveSize(this):0,function(v){return fn(v,reverse?--ii:ii++,this$0)}),reverse)};ToKeyedSequence.prototype.__iterator=function(type,reverse){if(this._useKeys){return this._iter.__iterator(type,reverse)}var iterator=this._iter.__iterator(ITERATE_VALUES,reverse);var ii=reverse?resolveSize(this):0;return new src_Iterator__Iterator(function(){var step=iterator.next();return step.done?step:iteratorValue(type,reverse?--ii:ii++,step.value,step)})};ToKeyedSequence.prototype[IS_ORDERED_SENTINEL]=true;createClass(ToIndexedSequence,IndexedSeq);function ToIndexedSequence(iter){this._iter=iter;this.size=iter.size}ToIndexedSequence.prototype.includes=function(value){return this._iter.includes(value)};ToIndexedSequence.prototype.__iterate=function(fn,reverse){var this$0=this;var iterations=0;return this._iter.__iterate(function(v){return fn(v,iterations++,this$0)},reverse)};ToIndexedSequence.prototype.__iterator=function(type,reverse){var iterator=this._iter.__iterator(ITERATE_VALUES,reverse);var iterations=0;return new src_Iterator__Iterator(function(){var step=iterator.next();return step.done?step:iteratorValue(type,iterations++,step.value,step)})};createClass(ToSetSequence,SetSeq);function ToSetSequence(iter){this._iter=iter;this.size=iter.size}ToSetSequence.prototype.has=function(key){return this._iter.includes(key)};ToSetSequence.prototype.__iterate=function(fn,reverse){var this$0=this;return this._iter.__iterate(function(v){return fn(v,v,this$0)},reverse)};ToSetSequence.prototype.__iterator=function(type,reverse){var iterator=this._iter.__iterator(ITERATE_VALUES,reverse);return new src_Iterator__Iterator(function(){var step=iterator.next();return step.done?step:iteratorValue(type,step.value,step.value,step)})};createClass(FromEntriesSequence,KeyedSeq);function FromEntriesSequence(entries){this._iter=entries;this.size=entries.size}FromEntriesSequence.prototype.entrySeq=function(){return this._iter.toSeq()};FromEntriesSequence.prototype.__iterate=function(fn,reverse){var this$0=this;return this._iter.__iterate(function(entry){if(entry){validateEntry(entry);var indexedIterable=isIterable(entry);return fn(indexedIterable?entry.get(1):entry[1],indexedIterable?entry.get(0):entry[0],this$0)}},reverse)};FromEntriesSequence.prototype.__iterator=function(type,reverse){var iterator=this._iter.__iterator(ITERATE_VALUES,reverse);return new src_Iterator__Iterator(function(){while(true){var step=iterator.next();if(step.done){return step}var entry=step.value;if(entry){validateEntry(entry);var indexedIterable=isIterable(entry);return iteratorValue(type,indexedIterable?entry.get(0):entry[0],indexedIterable?entry.get(1):entry[1],step)}}})};ToIndexedSequence.prototype.cacheResult=ToKeyedSequence.prototype.cacheResult=ToSetSequence.prototype.cacheResult=FromEntriesSequence.prototype.cacheResult=cacheResultThrough;function flipFactory(iterable){var flipSequence=makeSequence(iterable);flipSequence._iter=iterable;flipSequence.size=iterable.size;flipSequence.flip=function(){return iterable};flipSequence.reverse=function(){var reversedSequence=iterable.reverse.apply(this);reversedSequence.flip=function(){return iterable.reverse()};return reversedSequence};flipSequence.has=function(key){return iterable.includes(key)};flipSequence.includes=function(key){return iterable.has(key)};flipSequence.cacheResult=cacheResultThrough;flipSequence.__iterateUncached=function(fn,reverse){var this$0=this;return iterable.__iterate(function(v,k){return fn(k,v,this$0)!==false},reverse)};flipSequence.__iteratorUncached=function(type,reverse){if(type===ITERATE_ENTRIES){var iterator=iterable.__iterator(type,reverse);return new src_Iterator__Iterator(function(){var step=iterator.next();if(!step.done){var k=step.value[0];step.value[0]=step.value[1];step.value[1]=k}return step})}return iterable.__iterator(type===ITERATE_VALUES?ITERATE_KEYS:ITERATE_VALUES,reverse); | |
};return flipSequence}function mapFactory(iterable,mapper,context){var mappedSequence=makeSequence(iterable);mappedSequence.size=iterable.size;mappedSequence.has=function(key){return iterable.has(key)};mappedSequence.get=function(key,notSetValue){var v=iterable.get(key,NOT_SET);return v===NOT_SET?notSetValue:mapper.call(context,v,key,iterable)};mappedSequence.__iterateUncached=function(fn,reverse){var this$0=this;return iterable.__iterate(function(v,k,c){return fn(mapper.call(context,v,k,c),k,this$0)!==false},reverse)};mappedSequence.__iteratorUncached=function(type,reverse){var iterator=iterable.__iterator(ITERATE_ENTRIES,reverse);return new src_Iterator__Iterator(function(){var step=iterator.next();if(step.done){return step}var entry=step.value;var key=entry[0];return iteratorValue(type,key,mapper.call(context,entry[1],key,iterable),step)})};return mappedSequence}function reverseFactory(iterable,useKeys){var reversedSequence=makeSequence(iterable);reversedSequence._iter=iterable;reversedSequence.size=iterable.size;reversedSequence.reverse=function(){return iterable};if(iterable.flip){reversedSequence.flip=function(){var flipSequence=flipFactory(iterable);flipSequence.reverse=function(){return iterable.flip()};return flipSequence}}reversedSequence.get=function(key,notSetValue){return iterable.get(useKeys?key:-1-key,notSetValue)};reversedSequence.has=function(key){return iterable.has(useKeys?key:-1-key)};reversedSequence.includes=function(value){return iterable.includes(value)};reversedSequence.cacheResult=cacheResultThrough;reversedSequence.__iterate=function(fn,reverse){var this$0=this;return iterable.__iterate(function(v,k){return fn(v,k,this$0)},!reverse)};reversedSequence.__iterator=function(type,reverse){return iterable.__iterator(type,!reverse)};return reversedSequence}function filterFactory(iterable,predicate,context,useKeys){var filterSequence=makeSequence(iterable);if(useKeys){filterSequence.has=function(key){var v=iterable.get(key,NOT_SET);return v!==NOT_SET&&!!predicate.call(context,v,key,iterable)};filterSequence.get=function(key,notSetValue){var v=iterable.get(key,NOT_SET);return v!==NOT_SET&&predicate.call(context,v,key,iterable)?v:notSetValue}}filterSequence.__iterateUncached=function(fn,reverse){var this$0=this;var iterations=0;iterable.__iterate(function(v,k,c){if(predicate.call(context,v,k,c)){iterations++;return fn(v,useKeys?k:iterations-1,this$0)}},reverse);return iterations};filterSequence.__iteratorUncached=function(type,reverse){var iterator=iterable.__iterator(ITERATE_ENTRIES,reverse);var iterations=0;return new src_Iterator__Iterator(function(){while(true){var step=iterator.next();if(step.done){return step}var entry=step.value;var key=entry[0];var value=entry[1];if(predicate.call(context,value,key,iterable)){return iteratorValue(type,useKeys?key:iterations++,value,step)}}})};return filterSequence}function countByFactory(iterable,grouper,context){var groups=src_Map__Map().asMutable();iterable.__iterate(function(v,k){groups.update(grouper.call(context,v,k,iterable),0,function(a){return a+1})});return groups.asImmutable()}function groupByFactory(iterable,grouper,context){var isKeyedIter=isKeyed(iterable);var groups=(isOrdered(iterable)?OrderedMap():src_Map__Map()).asMutable();iterable.__iterate(function(v,k){groups.update(grouper.call(context,v,k,iterable),function(a){return a=a||[],a.push(isKeyedIter?[k,v]:v),a})});var coerce=iterableClass(iterable);return groups.map(function(arr){return reify(iterable,coerce(arr))})}function sliceFactory(iterable,begin,end,useKeys){var originalSize=iterable.size;if(wholeSlice(begin,end,originalSize)){return iterable}var resolvedBegin=resolveBegin(begin,originalSize);var resolvedEnd=resolveEnd(end,originalSize);if(resolvedBegin!==resolvedBegin||resolvedEnd!==resolvedEnd){return sliceFactory(iterable.toSeq().cacheResult(),begin,end,useKeys)}var resolvedSize=resolvedEnd-resolvedBegin;var sliceSize;if(resolvedSize===resolvedSize){sliceSize=resolvedSize<0?0:resolvedSize}var sliceSeq=makeSequence(iterable);sliceSeq.size=sliceSize;if(!useKeys&&isSeq(iterable)&&sliceSize>=0){sliceSeq.get=function(index,notSetValue){index=wrapIndex(this,index);return index>=0&&index<sliceSize?iterable.get(index+resolvedBegin,notSetValue):notSetValue}}sliceSeq.__iterateUncached=function(fn,reverse){var this$0=this;if(sliceSize===0){return 0}if(reverse){return this.cacheResult().__iterate(fn,reverse)}var skipped=0;var isSkipping=true;var iterations=0;iterable.__iterate(function(v,k){if(!(isSkipping&&(isSkipping=skipped++<resolvedBegin))){iterations++;return fn(v,useKeys?k:iterations-1,this$0)!==false&&iterations!==sliceSize}});return iterations};sliceSeq.__iteratorUncached=function(type,reverse){if(sliceSize!==0&&reverse){return this.cacheResult().__iterator(type,reverse)}var iterator=sliceSize!==0&&iterable.__iterator(type,reverse);var skipped=0;var iterations=0;return new src_Iterator__Iterator(function(){while(skipped++<resolvedBegin){iterator.next()}if(++iterations>sliceSize){return iteratorDone()}var step=iterator.next();if(useKeys||type===ITERATE_VALUES){return step}else if(type===ITERATE_KEYS){return iteratorValue(type,iterations-1,undefined,step)}else{return iteratorValue(type,iterations-1,step.value[1],step)}})};return sliceSeq}function takeWhileFactory(iterable,predicate,context){var takeSequence=makeSequence(iterable);takeSequence.__iterateUncached=function(fn,reverse){var this$0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse)}var iterations=0;iterable.__iterate(function(v,k,c){return predicate.call(context,v,k,c)&&++iterations&&fn(v,k,this$0)});return iterations};takeSequence.__iteratorUncached=function(type,reverse){var this$0=this;if(reverse){return this.cacheResult().__iterator(type,reverse)}var iterator=iterable.__iterator(ITERATE_ENTRIES,reverse);var iterating=true;return new src_Iterator__Iterator(function(){if(!iterating){return iteratorDone()}var step=iterator.next();if(step.done){return step}var entry=step.value;var k=entry[0];var v=entry[1];if(!predicate.call(context,v,k,this$0)){iterating=false;return iteratorDone()}return type===ITERATE_ENTRIES?step:iteratorValue(type,k,v,step)})};return takeSequence}function skipWhileFactory(iterable,predicate,context,useKeys){var skipSequence=makeSequence(iterable);skipSequence.__iterateUncached=function(fn,reverse){var this$0=this;if(reverse){return this.cacheResult().__iterate(fn,reverse)}var isSkipping=true;var iterations=0;iterable.__iterate(function(v,k,c){if(!(isSkipping&&(isSkipping=predicate.call(context,v,k,c)))){iterations++;return fn(v,useKeys?k:iterations-1,this$0)}});return iterations};skipSequence.__iteratorUncached=function(type,reverse){var this$0=this;if(reverse){return this.cacheResult().__iterator(type,reverse)}var iterator=iterable.__iterator(ITERATE_ENTRIES,reverse);var skipping=true;var iterations=0;return new src_Iterator__Iterator(function(){var step,k,v;do{step=iterator.next();if(step.done){if(useKeys||type===ITERATE_VALUES){return step}else if(type===ITERATE_KEYS){return iteratorValue(type,iterations++,undefined,step)}else{return iteratorValue(type,iterations++,step.value[1],step)}}var entry=step.value;k=entry[0];v=entry[1];skipping&&(skipping=predicate.call(context,v,k,this$0))}while(skipping);return type===ITERATE_ENTRIES?step:iteratorValue(type,k,v,step)})};return skipSequence}function concatFactory(iterable,values){var isKeyedIterable=isKeyed(iterable);var iters=[iterable].concat(values).map(function(v){if(!isIterable(v)){v=isKeyedIterable?keyedSeqFromValue(v):indexedSeqFromValue(Array.isArray(v)?v:[v])}else if(isKeyedIterable){v=KeyedIterable(v)}return v}).filter(function(v){return v.size!==0});if(iters.length===0){return iterable}if(iters.length===1){var singleton=iters[0];if(singleton===iterable||isKeyedIterable&&isKeyed(singleton)||isIndexed(iterable)&&isIndexed(singleton)){return singleton}}var concatSeq=new ArraySeq(iters);if(isKeyedIterable){concatSeq=concatSeq.toKeyedSeq()}else if(!isIndexed(iterable)){concatSeq=concatSeq.toSetSeq()}concatSeq=concatSeq.flatten(true);concatSeq.size=iters.reduce(function(sum,seq){if(sum!==undefined){var size=seq.size;if(size!==undefined){return sum+size}}},0);return concatSeq}function flattenFactory(iterable,depth,useKeys){var flatSequence=makeSequence(iterable);flatSequence.__iterateUncached=function(fn,reverse){var iterations=0;var stopped=false;function flatDeep(iter,currentDepth){var this$0=this;iter.__iterate(function(v,k){if((!depth||currentDepth<depth)&&isIterable(v)){flatDeep(v,currentDepth+1)}else if(fn(v,useKeys?k:iterations++,this$0)===false){stopped=true}return!stopped},reverse)}flatDeep(iterable,0);return iterations};flatSequence.__iteratorUncached=function(type,reverse){var iterator=iterable.__iterator(type,reverse);var stack=[];var iterations=0;return new src_Iterator__Iterator(function(){while(iterator){var step=iterator.next();if(step.done!==false){iterator=stack.pop();continue}var v=step.value;if(type===ITERATE_ENTRIES){v=v[1]}if((!depth||stack.length<depth)&&isIterable(v)){stack.push(iterator);iterator=v.__iterator(type,reverse)}else{return useKeys?step:iteratorValue(type,iterations++,v,step)}}return iteratorDone()})};return flatSequence}function flatMapFactory(iterable,mapper,context){var coerce=iterableClass(iterable);return iterable.toSeq().map(function(v,k){return coerce(mapper.call(context,v,k,iterable))}).flatten(true)}function interposeFactory(iterable,separator){var interposedSequence=makeSequence(iterable);interposedSequence.size=iterable.size&&iterable.size*2-1;interposedSequence.__iterateUncached=function(fn,reverse){var this$0=this;var iterations=0;iterable.__iterate(function(v,k){return(!iterations||fn(separator,iterations++,this$0)!==false)&&fn(v,iterations++,this$0)!==false},reverse);return iterations};interposedSequence.__iteratorUncached=function(type,reverse){var iterator=iterable.__iterator(ITERATE_VALUES,reverse);var iterations=0;var step;return new src_Iterator__Iterator(function(){if(!step||iterations%2){step=iterator.next();if(step.done){return step}}return iterations%2?iteratorValue(type,iterations++,separator):iteratorValue(type,iterations++,step.value,step)})};return interposedSequence}function sortFactory(iterable,comparator,mapper){if(!comparator){comparator=defaultComparator}var isKeyedIterable=isKeyed(iterable);var index=0;var entries=iterable.toSeq().map(function(v,k){return[k,v,index++,mapper?mapper(v,k,iterable):v]}).toArray();entries.sort(function(a,b){return comparator(a[3],b[3])||a[2]-b[2]}).forEach(isKeyedIterable?function(v,i){entries[i].length=2}:function(v,i){entries[i]=v[1]});return isKeyedIterable?KeyedSeq(entries):isIndexed(iterable)?IndexedSeq(entries):SetSeq(entries)}function maxFactory(iterable,comparator,mapper){if(!comparator){comparator=defaultComparator}if(mapper){var entry=iterable.toSeq().map(function(v,k){return[v,mapper(v,k,iterable)]}).reduce(function(a,b){return maxCompare(comparator,a[1],b[1])?b:a});return entry&&entry[0]}else{return iterable.reduce(function(a,b){return maxCompare(comparator,a,b)?b:a})}}function maxCompare(comparator,a,b){var comp=comparator(b,a);return comp===0&&b!==a&&(b===undefined||b===null||b!==b)||comp>0}function zipWithFactory(keyIter,zipper,iters){var zipSequence=makeSequence(keyIter);zipSequence.size=new ArraySeq(iters).map(function(i){return i.size}).min();zipSequence.__iterate=function(fn,reverse){var iterator=this.__iterator(ITERATE_VALUES,reverse);var step;var iterations=0;while(!(step=iterator.next()).done){if(fn(step.value,iterations++,this)===false){break}}return iterations};zipSequence.__iteratorUncached=function(type,reverse){var iterators=iters.map(function(i){return i=Iterable(i),getIterator(reverse?i.reverse():i)});var iterations=0;var isDone=false;return new src_Iterator__Iterator(function(){var steps;if(!isDone){steps=iterators.map(function(i){return i.next()});isDone=steps.some(function(s){return s.done})}if(isDone){return iteratorDone()}return iteratorValue(type,iterations++,zipper.apply(null,steps.map(function(s){return s.value})))})};return zipSequence}function reify(iter,seq){return isSeq(iter)?seq:iter.constructor(seq)}function validateEntry(entry){if(entry!==Object(entry)){throw new TypeError("Expected [K, V] tuple: "+entry)}}function resolveSize(iter){assertNotInfinite(iter.size);return ensureSize(iter)}function iterableClass(iterable){return isKeyed(iterable)?KeyedIterable:isIndexed(iterable)?IndexedIterable:SetIterable}function makeSequence(iterable){return Object.create((isKeyed(iterable)?KeyedSeq:isIndexed(iterable)?IndexedSeq:SetSeq).prototype)}function cacheResultThrough(){if(this._iter.cacheResult){this._iter.cacheResult();this.size=this._iter.size;return this}else{return Seq.prototype.cacheResult.call(this)}}function defaultComparator(a,b){return a>b?1:a<b?-1:0}function forceIterator(keyPath){var iter=getIterator(keyPath);if(!iter){if(!isArrayLike(keyPath)){throw new TypeError("Expected iterable or array-like: "+keyPath)}iter=getIterator(Iterable(keyPath))}return iter}createClass(src_Map__Map,KeyedCollection);function src_Map__Map(value){return value===null||value===undefined?emptyMap():isMap(value)?value:emptyMap().withMutations(function(map){var iter=KeyedIterable(value);assertNotInfinite(iter.size);iter.forEach(function(v,k){return map.set(k,v)})})}src_Map__Map.prototype.toString=function(){return this.__toString("Map {","}")};src_Map__Map.prototype.get=function(k,notSetValue){return this._root?this._root.get(0,undefined,k,notSetValue):notSetValue};src_Map__Map.prototype.set=function(k,v){return updateMap(this,k,v)};src_Map__Map.prototype.setIn=function(keyPath,v){return this.updateIn(keyPath,NOT_SET,function(){return v})};src_Map__Map.prototype.remove=function(k){return updateMap(this,k,NOT_SET)};src_Map__Map.prototype.deleteIn=function(keyPath){return this.updateIn(keyPath,function(){return NOT_SET})};src_Map__Map.prototype.update=function(k,notSetValue,updater){return arguments.length===1?k(this):this.updateIn([k],notSetValue,updater)};src_Map__Map.prototype.updateIn=function(keyPath,notSetValue,updater){if(!updater){updater=notSetValue;notSetValue=undefined}var updatedValue=updateInDeepMap(this,forceIterator(keyPath),notSetValue,updater);return updatedValue===NOT_SET?undefined:updatedValue};src_Map__Map.prototype.clear=function(){if(this.size===0){return this}if(this.__ownerID){this.size=0;this._root=null;this.__hash=undefined;this.__altered=true;return this}return emptyMap()};src_Map__Map.prototype.merge=function(){return mergeIntoMapWith(this,undefined,arguments)};src_Map__Map.prototype.mergeWith=function(merger){var iters=SLICE$0.call(arguments,1);return mergeIntoMapWith(this,merger,iters)};src_Map__Map.prototype.mergeIn=function(keyPath){var iters=SLICE$0.call(arguments,1);return this.updateIn(keyPath,emptyMap(),function(m){return typeof m.merge==="function"?m.merge.apply(m,iters):iters[iters.length-1]})};src_Map__Map.prototype.mergeDeep=function(){return mergeIntoMapWith(this,deepMerger(undefined),arguments)};src_Map__Map.prototype.mergeDeepWith=function(merger){var iters=SLICE$0.call(arguments,1);return mergeIntoMapWith(this,deepMerger(merger),iters)};src_Map__Map.prototype.mergeDeepIn=function(keyPath){var iters=SLICE$0.call(arguments,1);return this.updateIn(keyPath,emptyMap(),function(m){return typeof m.mergeDeep==="function"?m.mergeDeep.apply(m,iters):iters[iters.length-1]})};src_Map__Map.prototype.sort=function(comparator){return OrderedMap(sortFactory(this,comparator))};src_Map__Map.prototype.sortBy=function(mapper,comparator){return OrderedMap(sortFactory(this,comparator,mapper))};src_Map__Map.prototype.withMutations=function(fn){var mutable=this.asMutable();fn(mutable);return mutable.wasAltered()?mutable.__ensureOwner(this.__ownerID):this};src_Map__Map.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new OwnerID)};src_Map__Map.prototype.asImmutable=function(){return this.__ensureOwner()};src_Map__Map.prototype.wasAltered=function(){return this.__altered};src_Map__Map.prototype.__iterator=function(type,reverse){return new MapIterator(this,type,reverse)};src_Map__Map.prototype.__iterate=function(fn,reverse){var this$0=this;var iterations=0;this._root&&this._root.iterate(function(entry){iterations++;return fn(entry[1],entry[0],this$0)},reverse);return iterations};src_Map__Map.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}if(!ownerID){this.__ownerID=ownerID;this.__altered=false;return this}return makeMap(this.size,this._root,ownerID,this.__hash)};function isMap(maybeMap){return!!(maybeMap&&maybeMap[IS_MAP_SENTINEL])}src_Map__Map.isMap=isMap;var IS_MAP_SENTINEL="@@__IMMUTABLE_MAP__@@";var MapPrototype=src_Map__Map.prototype;MapPrototype[IS_MAP_SENTINEL]=true;MapPrototype[DELETE]=MapPrototype.remove;MapPrototype.removeIn=MapPrototype.deleteIn;function ArrayMapNode(ownerID,entries){this.ownerID=ownerID;this.entries=entries}ArrayMapNode.prototype.get=function(shift,keyHash,key,notSetValue){var entries=this.entries;for(var ii=0,len=entries.length;ii<len;ii++){if(is(key,entries[ii][0])){return entries[ii][1]}}return notSetValue};ArrayMapNode.prototype.update=function(ownerID,shift,keyHash,key,value,didChangeSize,didAlter){var removed=value===NOT_SET;var entries=this.entries;var idx=0;for(var len=entries.length;idx<len;idx++){if(is(key,entries[idx][0])){break}}var exists=idx<len;if(exists?entries[idx][1]===value:removed){return this}SetRef(didAlter);(removed||!exists)&&SetRef(didChangeSize);if(removed&&entries.length===1){return}if(!exists&&!removed&&entries.length>=MAX_ARRAY_MAP_SIZE){return createNodes(ownerID,entries,key,value)}var isEditable=ownerID&&ownerID===this.ownerID;var newEntries=isEditable?entries:arrCopy(entries);if(exists){if(removed){idx===len-1?newEntries.pop():newEntries[idx]=newEntries.pop()}else{newEntries[idx]=[key,value]}}else{newEntries.push([key,value])}if(isEditable){this.entries=newEntries;return this}return new ArrayMapNode(ownerID,newEntries)};function BitmapIndexedNode(ownerID,bitmap,nodes){this.ownerID=ownerID;this.bitmap=bitmap;this.nodes=nodes}BitmapIndexedNode.prototype.get=function(shift,keyHash,key,notSetValue){if(keyHash===undefined){keyHash=hash(key)}var bit=1<<((shift===0?keyHash:keyHash>>>shift)&MASK);var bitmap=this.bitmap;return(bitmap&bit)===0?notSetValue:this.nodes[popCount(bitmap&bit-1)].get(shift+SHIFT,keyHash,key,notSetValue)};BitmapIndexedNode.prototype.update=function(ownerID,shift,keyHash,key,value,didChangeSize,didAlter){if(keyHash===undefined){keyHash=hash(key)}var keyHashFrag=(shift===0?keyHash:keyHash>>>shift)&MASK;var bit=1<<keyHashFrag;var bitmap=this.bitmap;var exists=(bitmap&bit)!==0;if(!exists&&value===NOT_SET){return this}var idx=popCount(bitmap&bit-1);var nodes=this.nodes;var node=exists?nodes[idx]:undefined;var newNode=updateNode(node,ownerID,shift+SHIFT,keyHash,key,value,didChangeSize,didAlter);if(newNode===node){return this}if(!exists&&newNode&&nodes.length>=MAX_BITMAP_INDEXED_SIZE){return expandNodes(ownerID,nodes,bitmap,keyHashFrag,newNode)}if(exists&&!newNode&&nodes.length===2&&isLeafNode(nodes[idx^1])){return nodes[idx^1]}if(exists&&newNode&&nodes.length===1&&isLeafNode(newNode)){return newNode}var isEditable=ownerID&&ownerID===this.ownerID;var newBitmap=exists?newNode?bitmap:bitmap^bit:bitmap|bit;var newNodes=exists?newNode?setIn(nodes,idx,newNode,isEditable):spliceOut(nodes,idx,isEditable):spliceIn(nodes,idx,newNode,isEditable);if(isEditable){this.bitmap=newBitmap;this.nodes=newNodes;return this}return new BitmapIndexedNode(ownerID,newBitmap,newNodes)};function HashArrayMapNode(ownerID,count,nodes){this.ownerID=ownerID;this.count=count;this.nodes=nodes}HashArrayMapNode.prototype.get=function(shift,keyHash,key,notSetValue){if(keyHash===undefined){keyHash=hash(key)}var idx=(shift===0?keyHash:keyHash>>>shift)&MASK;var node=this.nodes[idx];return node?node.get(shift+SHIFT,keyHash,key,notSetValue):notSetValue};HashArrayMapNode.prototype.update=function(ownerID,shift,keyHash,key,value,didChangeSize,didAlter){if(keyHash===undefined){keyHash=hash(key)}var idx=(shift===0?keyHash:keyHash>>>shift)&MASK;var removed=value===NOT_SET;var nodes=this.nodes;var node=nodes[idx];if(removed&&!node){return this}var newNode=updateNode(node,ownerID,shift+SHIFT,keyHash,key,value,didChangeSize,didAlter);if(newNode===node){return this}var newCount=this.count;if(!node){newCount++}else if(!newNode){newCount--;if(newCount<MIN_HASH_ARRAY_MAP_SIZE){return packNodes(ownerID,nodes,newCount,idx)}}var isEditable=ownerID&&ownerID===this.ownerID;var newNodes=setIn(nodes,idx,newNode,isEditable);if(isEditable){this.count=newCount;this.nodes=newNodes;return this}return new HashArrayMapNode(ownerID,newCount,newNodes)};function HashCollisionNode(ownerID,keyHash,entries){this.ownerID=ownerID;this.keyHash=keyHash;this.entries=entries}HashCollisionNode.prototype.get=function(shift,keyHash,key,notSetValue){var entries=this.entries;for(var ii=0,len=entries.length;ii<len;ii++){if(is(key,entries[ii][0])){return entries[ii][1]}}return notSetValue};HashCollisionNode.prototype.update=function(ownerID,shift,keyHash,key,value,didChangeSize,didAlter){if(keyHash===undefined){keyHash=hash(key)}var removed=value===NOT_SET;if(keyHash!==this.keyHash){if(removed){return this}SetRef(didAlter);SetRef(didChangeSize);return mergeIntoNode(this,ownerID,shift,keyHash,[key,value])}var entries=this.entries;var idx=0;for(var len=entries.length;idx<len;idx++){if(is(key,entries[idx][0])){break}}var exists=idx<len;if(exists?entries[idx][1]===value:removed){return this}SetRef(didAlter);(removed||!exists)&&SetRef(didChangeSize);if(removed&&len===2){return new ValueNode(ownerID,this.keyHash,entries[idx^1])}var isEditable=ownerID&&ownerID===this.ownerID;var newEntries=isEditable?entries:arrCopy(entries);if(exists){if(removed){idx===len-1?newEntries.pop():newEntries[idx]=newEntries.pop()}else{newEntries[idx]=[key,value]}}else{newEntries.push([key,value])}if(isEditable){this.entries=newEntries;return this}return new HashCollisionNode(ownerID,this.keyHash,newEntries)};function ValueNode(ownerID,keyHash,entry){this.ownerID=ownerID;this.keyHash=keyHash;this.entry=entry}ValueNode.prototype.get=function(shift,keyHash,key,notSetValue){return is(key,this.entry[0])?this.entry[1]:notSetValue};ValueNode.prototype.update=function(ownerID,shift,keyHash,key,value,didChangeSize,didAlter){var removed=value===NOT_SET;var keyMatch=is(key,this.entry[0]);if(keyMatch?value===this.entry[1]:removed){return this}SetRef(didAlter);if(removed){SetRef(didChangeSize);return}if(keyMatch){if(ownerID&&ownerID===this.ownerID){this.entry[1]=value;return this}return new ValueNode(ownerID,this.keyHash,[key,value])}SetRef(didChangeSize);return mergeIntoNode(this,ownerID,shift,hash(key),[key,value])};ArrayMapNode.prototype.iterate=HashCollisionNode.prototype.iterate=function(fn,reverse){var entries=this.entries;for(var ii=0,maxIndex=entries.length-1;ii<=maxIndex;ii++){if(fn(entries[reverse?maxIndex-ii:ii])===false){return false}}};BitmapIndexedNode.prototype.iterate=HashArrayMapNode.prototype.iterate=function(fn,reverse){var nodes=this.nodes;for(var ii=0,maxIndex=nodes.length-1;ii<=maxIndex;ii++){var node=nodes[reverse?maxIndex-ii:ii];if(node&&node.iterate(fn,reverse)===false){return false}}};ValueNode.prototype.iterate=function(fn,reverse){return fn(this.entry)};createClass(MapIterator,src_Iterator__Iterator);function MapIterator(map,type,reverse){this._type=type;this._reverse=reverse;this._stack=map._root&&mapIteratorFrame(map._root)}MapIterator.prototype.next=function(){var type=this._type;var stack=this._stack;while(stack){var node=stack.node;var index=stack.index++;var maxIndex;if(node.entry){if(index===0){return mapIteratorValue(type,node.entry)}}else if(node.entries){maxIndex=node.entries.length-1;if(index<=maxIndex){return mapIteratorValue(type,node.entries[this._reverse?maxIndex-index:index])}}else{maxIndex=node.nodes.length-1;if(index<=maxIndex){var subNode=node.nodes[this._reverse?maxIndex-index:index];if(subNode){if(subNode.entry){return mapIteratorValue(type,subNode.entry)}stack=this._stack=mapIteratorFrame(subNode,stack)}continue}}stack=this._stack=this._stack.__prev}return iteratorDone()};function mapIteratorValue(type,entry){return iteratorValue(type,entry[0],entry[1])}function mapIteratorFrame(node,prev){return{node:node,index:0,__prev:prev}}function makeMap(size,root,ownerID,hash){var map=Object.create(MapPrototype);map.size=size;map._root=root;map.__ownerID=ownerID;map.__hash=hash;map.__altered=false;return map}var EMPTY_MAP;function emptyMap(){return EMPTY_MAP||(EMPTY_MAP=makeMap(0))}function updateMap(map,k,v){var newRoot;var newSize;if(!map._root){if(v===NOT_SET){return map}newSize=1;newRoot=new ArrayMapNode(map.__ownerID,[[k,v]])}else{var didChangeSize=MakeRef(CHANGE_LENGTH);var didAlter=MakeRef(DID_ALTER);newRoot=updateNode(map._root,map.__ownerID,0,undefined,k,v,didChangeSize,didAlter);if(!didAlter.value){return map}newSize=map.size+(didChangeSize.value?v===NOT_SET?-1:1:0)}if(map.__ownerID){map.size=newSize;map._root=newRoot;map.__hash=undefined;map.__altered=true;return map}return newRoot?makeMap(newSize,newRoot):emptyMap()}function updateNode(node,ownerID,shift,keyHash,key,value,didChangeSize,didAlter){if(!node){if(value===NOT_SET){return node}SetRef(didAlter);SetRef(didChangeSize);return new ValueNode(ownerID,keyHash,[key,value])}return node.update(ownerID,shift,keyHash,key,value,didChangeSize,didAlter)}function isLeafNode(node){return node.constructor===ValueNode||node.constructor===HashCollisionNode}function mergeIntoNode(node,ownerID,shift,keyHash,entry){if(node.keyHash===keyHash){return new HashCollisionNode(ownerID,keyHash,[node.entry,entry])}var idx1=(shift===0?node.keyHash:node.keyHash>>>shift)&MASK;var idx2=(shift===0?keyHash:keyHash>>>shift)&MASK;var newNode;var nodes=idx1===idx2?[mergeIntoNode(node,ownerID,shift+SHIFT,keyHash,entry)]:(newNode=new ValueNode(ownerID,keyHash,entry),idx1<idx2?[node,newNode]:[newNode,node]);return new BitmapIndexedNode(ownerID,1<<idx1|1<<idx2,nodes)}function createNodes(ownerID,entries,key,value){if(!ownerID){ownerID=new OwnerID}var node=new ValueNode(ownerID,hash(key),[key,value]);for(var ii=0;ii<entries.length;ii++){var entry=entries[ii];node=node.update(ownerID,0,undefined,entry[0],entry[1])}return node}function packNodes(ownerID,nodes,count,excluding){var bitmap=0;var packedII=0;var packedNodes=new Array(count);for(var ii=0,bit=1,len=nodes.length;ii<len;ii++,bit<<=1){var node=nodes[ii];if(node!==undefined&&ii!==excluding){bitmap|=bit;packedNodes[packedII++]=node}}return new BitmapIndexedNode(ownerID,bitmap,packedNodes)}function expandNodes(ownerID,nodes,bitmap,including,node){var count=0;var expandedNodes=new Array(SIZE);for(var ii=0;bitmap!==0;ii++,bitmap>>>=1){expandedNodes[ii]=bitmap&1?nodes[count++]:undefined}expandedNodes[including]=node;return new HashArrayMapNode(ownerID,count+1,expandedNodes)}function mergeIntoMapWith(map,merger,iterables){var iters=[];for(var ii=0;ii<iterables.length;ii++){var value=iterables[ii];var iter=KeyedIterable(value);if(!isIterable(value)){iter=iter.map(function(v){return fromJS(v)})}iters.push(iter)}return mergeIntoCollectionWith(map,merger,iters)}function deepMerger(merger){return function(existing,value,key){return existing&&existing.mergeDeepWith&&isIterable(value)?existing.mergeDeepWith(merger,value):merger?merger(existing,value,key):value}}function mergeIntoCollectionWith(collection,merger,iters){iters=iters.filter(function(x){return x.size!==0});if(iters.length===0){return collection}if(collection.size===0&&!collection.__ownerID&&iters.length===1){return collection.constructor(iters[0])}return collection.withMutations(function(collection){var mergeIntoMap=merger?function(value,key){collection.update(key,NOT_SET,function(existing){return existing===NOT_SET?value:merger(existing,value,key)})}:function(value,key){collection.set(key,value)};for(var ii=0;ii<iters.length;ii++){iters[ii].forEach(mergeIntoMap)}})}function updateInDeepMap(existing,keyPathIter,notSetValue,updater){var isNotSet=existing===NOT_SET;var step=keyPathIter.next();if(step.done){var existingValue=isNotSet?notSetValue:existing;var newValue=updater(existingValue);return newValue===existingValue?existing:newValue}invariant(isNotSet||existing&&existing.set,"invalid keyPath");var key=step.value;var nextExisting=isNotSet?NOT_SET:existing.get(key,NOT_SET);var nextUpdated=updateInDeepMap(nextExisting,keyPathIter,notSetValue,updater);return nextUpdated===nextExisting?existing:nextUpdated===NOT_SET?existing.remove(key):(isNotSet?emptyMap():existing).set(key,nextUpdated)}function popCount(x){x=x-(x>>1&1431655765);x=(x&858993459)+(x>>2&858993459);x=x+(x>>4)&252645135;x=x+(x>>8);x=x+(x>>16);return x&127}function setIn(array,idx,val,canEdit){var newArray=canEdit?array:arrCopy(array);newArray[idx]=val;return newArray}function spliceIn(array,idx,val,canEdit){var newLen=array.length+1;if(canEdit&&idx+1===newLen){array[idx]=val;return array}var newArray=new Array(newLen);var after=0;for(var ii=0;ii<newLen;ii++){if(ii===idx){newArray[ii]=val;after=-1}else{newArray[ii]=array[ii+after]}}return newArray}function spliceOut(array,idx,canEdit){var newLen=array.length-1;if(canEdit&&idx===newLen){array.pop();return array}var newArray=new Array(newLen);var after=0;for(var ii=0;ii<newLen;ii++){if(ii===idx){after=1}newArray[ii]=array[ii+after]}return newArray}var MAX_ARRAY_MAP_SIZE=SIZE/4;var MAX_BITMAP_INDEXED_SIZE=SIZE/2;var MIN_HASH_ARRAY_MAP_SIZE=SIZE/4;createClass(List,IndexedCollection);function List(value){var empty=emptyList();if(value===null||value===undefined){return empty}if(isList(value)){return value}var iter=IndexedIterable(value);var size=iter.size;if(size===0){return empty}assertNotInfinite(size);if(size>0&&size<SIZE){return makeList(0,size,SHIFT,null,new VNode(iter.toArray()))}return empty.withMutations(function(list){list.setSize(size);iter.forEach(function(v,i){return list.set(i,v)})})}List.of=function(){return this(arguments)};List.prototype.toString=function(){return this.__toString("List [","]")};List.prototype.get=function(index,notSetValue){index=wrapIndex(this,index);if(index<0||index>=this.size){return notSetValue}index+=this._origin;var node=listNodeFor(this,index);return node&&node.array[index&MASK]};List.prototype.set=function(index,value){return updateList(this,index,value)};List.prototype.remove=function(index){return!this.has(index)?this:index===0?this.shift():index===this.size-1?this.pop():this.splice(index,1)};List.prototype.clear=function(){if(this.size===0){return this}if(this.__ownerID){this.size=this._origin=this._capacity=0;this._level=SHIFT;this._root=this._tail=null;this.__hash=undefined;this.__altered=true;return this}return emptyList()};List.prototype.push=function(){var values=arguments;var oldSize=this.size;return this.withMutations(function(list){setListBounds(list,0,oldSize+values.length);for(var ii=0;ii<values.length;ii++){list.set(oldSize+ii,values[ii])}})};List.prototype.pop=function(){return setListBounds(this,0,-1)};List.prototype.unshift=function(){var values=arguments;return this.withMutations(function(list){setListBounds(list,-values.length);for(var ii=0;ii<values.length;ii++){list.set(ii,values[ii])}})};List.prototype.shift=function(){return setListBounds(this,1)};List.prototype.merge=function(){return mergeIntoListWith(this,undefined,arguments)};List.prototype.mergeWith=function(merger){var iters=SLICE$0.call(arguments,1);return mergeIntoListWith(this,merger,iters)};List.prototype.mergeDeep=function(){return mergeIntoListWith(this,deepMerger(undefined),arguments)};List.prototype.mergeDeepWith=function(merger){var iters=SLICE$0.call(arguments,1);return mergeIntoListWith(this,deepMerger(merger),iters)};List.prototype.setSize=function(size){return setListBounds(this,0,size)};List.prototype.slice=function(begin,end){var size=this.size;if(wholeSlice(begin,end,size)){return this}return setListBounds(this,resolveBegin(begin,size),resolveEnd(end,size))};List.prototype.__iterator=function(type,reverse){ | |
var index=0;var values=iterateList(this,reverse);return new src_Iterator__Iterator(function(){var value=values();return value===DONE?iteratorDone():iteratorValue(type,index++,value)})};List.prototype.__iterate=function(fn,reverse){var index=0;var values=iterateList(this,reverse);var value;while((value=values())!==DONE){if(fn(value,index++,this)===false){break}}return index};List.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}if(!ownerID){this.__ownerID=ownerID;return this}return makeList(this._origin,this._capacity,this._level,this._root,this._tail,ownerID,this.__hash)};function isList(maybeList){return!!(maybeList&&maybeList[IS_LIST_SENTINEL])}List.isList=isList;var IS_LIST_SENTINEL="@@__IMMUTABLE_LIST__@@";var ListPrototype=List.prototype;ListPrototype[IS_LIST_SENTINEL]=true;ListPrototype[DELETE]=ListPrototype.remove;ListPrototype.setIn=MapPrototype.setIn;ListPrototype.deleteIn=ListPrototype.removeIn=MapPrototype.removeIn;ListPrototype.update=MapPrototype.update;ListPrototype.updateIn=MapPrototype.updateIn;ListPrototype.mergeIn=MapPrototype.mergeIn;ListPrototype.mergeDeepIn=MapPrototype.mergeDeepIn;ListPrototype.withMutations=MapPrototype.withMutations;ListPrototype.asMutable=MapPrototype.asMutable;ListPrototype.asImmutable=MapPrototype.asImmutable;ListPrototype.wasAltered=MapPrototype.wasAltered;function VNode(array,ownerID){this.array=array;this.ownerID=ownerID}VNode.prototype.removeBefore=function(ownerID,level,index){if(index===level?1<<level:0||this.array.length===0){return this}var originIndex=index>>>level&MASK;if(originIndex>=this.array.length){return new VNode([],ownerID)}var removingFirst=originIndex===0;var newChild;if(level>0){var oldChild=this.array[originIndex];newChild=oldChild&&oldChild.removeBefore(ownerID,level-SHIFT,index);if(newChild===oldChild&&removingFirst){return this}}if(removingFirst&&!newChild){return this}var editable=editableVNode(this,ownerID);if(!removingFirst){for(var ii=0;ii<originIndex;ii++){editable.array[ii]=undefined}}if(newChild){editable.array[originIndex]=newChild}return editable};VNode.prototype.removeAfter=function(ownerID,level,index){if(index===level?1<<level:0||this.array.length===0){return this}var sizeIndex=index-1>>>level&MASK;if(sizeIndex>=this.array.length){return this}var removingLast=sizeIndex===this.array.length-1;var newChild;if(level>0){var oldChild=this.array[sizeIndex];newChild=oldChild&&oldChild.removeAfter(ownerID,level-SHIFT,index);if(newChild===oldChild&&removingLast){return this}}if(removingLast&&!newChild){return this}var editable=editableVNode(this,ownerID);if(!removingLast){editable.array.pop()}if(newChild){editable.array[sizeIndex]=newChild}return editable};var DONE={};function iterateList(list,reverse){var left=list._origin;var right=list._capacity;var tailPos=getTailOffset(right);var tail=list._tail;return iterateNodeOrLeaf(list._root,list._level,0);function iterateNodeOrLeaf(node,level,offset){return level===0?iterateLeaf(node,offset):iterateNode(node,level,offset)}function iterateLeaf(node,offset){var array=offset===tailPos?tail&&tail.array:node&&node.array;var from=offset>left?0:left-offset;var to=right-offset;if(to>SIZE){to=SIZE}return function(){if(from===to){return DONE}var idx=reverse?--to:from++;return array&&array[idx]}}function iterateNode(node,level,offset){var values;var array=node&&node.array;var from=offset>left?0:left-offset>>level;var to=(right-offset>>level)+1;if(to>SIZE){to=SIZE}return function(){do{if(values){var value=values();if(value!==DONE){return value}values=null}if(from===to){return DONE}var idx=reverse?--to:from++;values=iterateNodeOrLeaf(array&&array[idx],level-SHIFT,offset+(idx<<level))}while(true)}}}function makeList(origin,capacity,level,root,tail,ownerID,hash){var list=Object.create(ListPrototype);list.size=capacity-origin;list._origin=origin;list._capacity=capacity;list._level=level;list._root=root;list._tail=tail;list.__ownerID=ownerID;list.__hash=hash;list.__altered=false;return list}var EMPTY_LIST;function emptyList(){return EMPTY_LIST||(EMPTY_LIST=makeList(0,0,SHIFT))}function updateList(list,index,value){index=wrapIndex(list,index);if(index>=list.size||index<0){return list.withMutations(function(list){index<0?setListBounds(list,index).set(0,value):setListBounds(list,0,index+1).set(index,value)})}index+=list._origin;var newTail=list._tail;var newRoot=list._root;var didAlter=MakeRef(DID_ALTER);if(index>=getTailOffset(list._capacity)){newTail=updateVNode(newTail,list.__ownerID,0,index,value,didAlter)}else{newRoot=updateVNode(newRoot,list.__ownerID,list._level,index,value,didAlter)}if(!didAlter.value){return list}if(list.__ownerID){list._root=newRoot;list._tail=newTail;list.__hash=undefined;list.__altered=true;return list}return makeList(list._origin,list._capacity,list._level,newRoot,newTail)}function updateVNode(node,ownerID,level,index,value,didAlter){var idx=index>>>level&MASK;var nodeHas=node&&idx<node.array.length;if(!nodeHas&&value===undefined){return node}var newNode;if(level>0){var lowerNode=node&&node.array[idx];var newLowerNode=updateVNode(lowerNode,ownerID,level-SHIFT,index,value,didAlter);if(newLowerNode===lowerNode){return node}newNode=editableVNode(node,ownerID);newNode.array[idx]=newLowerNode;return newNode}if(nodeHas&&node.array[idx]===value){return node}SetRef(didAlter);newNode=editableVNode(node,ownerID);if(value===undefined&&idx===newNode.array.length-1){newNode.array.pop()}else{newNode.array[idx]=value}return newNode}function editableVNode(node,ownerID){if(ownerID&&node&&ownerID===node.ownerID){return node}return new VNode(node?node.array.slice():[],ownerID)}function listNodeFor(list,rawIndex){if(rawIndex>=getTailOffset(list._capacity)){return list._tail}if(rawIndex<1<<list._level+SHIFT){var node=list._root;var level=list._level;while(node&&level>0){node=node.array[rawIndex>>>level&MASK];level-=SHIFT}return node}}function setListBounds(list,begin,end){var owner=list.__ownerID||new OwnerID;var oldOrigin=list._origin;var oldCapacity=list._capacity;var newOrigin=oldOrigin+begin;var newCapacity=end===undefined?oldCapacity:end<0?oldCapacity+end:oldOrigin+end;if(newOrigin===oldOrigin&&newCapacity===oldCapacity){return list}if(newOrigin>=newCapacity){return list.clear()}var newLevel=list._level;var newRoot=list._root;var offsetShift=0;while(newOrigin+offsetShift<0){newRoot=new VNode(newRoot&&newRoot.array.length?[undefined,newRoot]:[],owner);newLevel+=SHIFT;offsetShift+=1<<newLevel}if(offsetShift){newOrigin+=offsetShift;oldOrigin+=offsetShift;newCapacity+=offsetShift;oldCapacity+=offsetShift}var oldTailOffset=getTailOffset(oldCapacity);var newTailOffset=getTailOffset(newCapacity);while(newTailOffset>=1<<newLevel+SHIFT){newRoot=new VNode(newRoot&&newRoot.array.length?[newRoot]:[],owner);newLevel+=SHIFT}var oldTail=list._tail;var newTail=newTailOffset<oldTailOffset?listNodeFor(list,newCapacity-1):newTailOffset>oldTailOffset?new VNode([],owner):oldTail;if(oldTail&&newTailOffset>oldTailOffset&&newOrigin<oldCapacity&&oldTail.array.length){newRoot=editableVNode(newRoot,owner);var node=newRoot;for(var level=newLevel;level>SHIFT;level-=SHIFT){var idx=oldTailOffset>>>level&MASK;node=node.array[idx]=editableVNode(node.array[idx],owner)}node.array[oldTailOffset>>>SHIFT&MASK]=oldTail}if(newCapacity<oldCapacity){newTail=newTail&&newTail.removeAfter(owner,0,newCapacity)}if(newOrigin>=newTailOffset){newOrigin-=newTailOffset;newCapacity-=newTailOffset;newLevel=SHIFT;newRoot=null;newTail=newTail&&newTail.removeBefore(owner,0,newOrigin)}else if(newOrigin>oldOrigin||newTailOffset<oldTailOffset){offsetShift=0;while(newRoot){var beginIndex=newOrigin>>>newLevel&MASK;if(beginIndex!==newTailOffset>>>newLevel&MASK){break}if(beginIndex){offsetShift+=(1<<newLevel)*beginIndex}newLevel-=SHIFT;newRoot=newRoot.array[beginIndex]}if(newRoot&&newOrigin>oldOrigin){newRoot=newRoot.removeBefore(owner,newLevel,newOrigin-offsetShift)}if(newRoot&&newTailOffset<oldTailOffset){newRoot=newRoot.removeAfter(owner,newLevel,newTailOffset-offsetShift)}if(offsetShift){newOrigin-=offsetShift;newCapacity-=offsetShift}}if(list.__ownerID){list.size=newCapacity-newOrigin;list._origin=newOrigin;list._capacity=newCapacity;list._level=newLevel;list._root=newRoot;list._tail=newTail;list.__hash=undefined;list.__altered=true;return list}return makeList(newOrigin,newCapacity,newLevel,newRoot,newTail)}function mergeIntoListWith(list,merger,iterables){var iters=[];var maxSize=0;for(var ii=0;ii<iterables.length;ii++){var value=iterables[ii];var iter=IndexedIterable(value);if(iter.size>maxSize){maxSize=iter.size}if(!isIterable(value)){iter=iter.map(function(v){return fromJS(v)})}iters.push(iter)}if(maxSize>list.size){list=list.setSize(maxSize)}return mergeIntoCollectionWith(list,merger,iters)}function getTailOffset(size){return size<SIZE?0:size-1>>>SHIFT<<SHIFT}createClass(OrderedMap,src_Map__Map);function OrderedMap(value){return value===null||value===undefined?emptyOrderedMap():isOrderedMap(value)?value:emptyOrderedMap().withMutations(function(map){var iter=KeyedIterable(value);assertNotInfinite(iter.size);iter.forEach(function(v,k){return map.set(k,v)})})}OrderedMap.of=function(){return this(arguments)};OrderedMap.prototype.toString=function(){return this.__toString("OrderedMap {","}")};OrderedMap.prototype.get=function(k,notSetValue){var index=this._map.get(k);return index!==undefined?this._list.get(index)[1]:notSetValue};OrderedMap.prototype.clear=function(){if(this.size===0){return this}if(this.__ownerID){this.size=0;this._map.clear();this._list.clear();return this}return emptyOrderedMap()};OrderedMap.prototype.set=function(k,v){return updateOrderedMap(this,k,v)};OrderedMap.prototype.remove=function(k){return updateOrderedMap(this,k,NOT_SET)};OrderedMap.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()};OrderedMap.prototype.__iterate=function(fn,reverse){var this$0=this;return this._list.__iterate(function(entry){return entry&&fn(entry[1],entry[0],this$0)},reverse)};OrderedMap.prototype.__iterator=function(type,reverse){return this._list.fromEntrySeq().__iterator(type,reverse)};OrderedMap.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map.__ensureOwner(ownerID);var newList=this._list.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;this._list=newList;return this}return makeOrderedMap(newMap,newList,ownerID,this.__hash)};function isOrderedMap(maybeOrderedMap){return isMap(maybeOrderedMap)&&isOrdered(maybeOrderedMap)}OrderedMap.isOrderedMap=isOrderedMap;OrderedMap.prototype[IS_ORDERED_SENTINEL]=true;OrderedMap.prototype[DELETE]=OrderedMap.prototype.remove;function makeOrderedMap(map,list,ownerID,hash){var omap=Object.create(OrderedMap.prototype);omap.size=map?map.size:0;omap._map=map;omap._list=list;omap.__ownerID=ownerID;omap.__hash=hash;return omap}var EMPTY_ORDERED_MAP;function emptyOrderedMap(){return EMPTY_ORDERED_MAP||(EMPTY_ORDERED_MAP=makeOrderedMap(emptyMap(),emptyList()))}function updateOrderedMap(omap,k,v){var map=omap._map;var list=omap._list;var i=map.get(k);var has=i!==undefined;var newMap;var newList;if(v===NOT_SET){if(!has){return omap}if(list.size>=SIZE&&list.size>=map.size*2){newList=list.filter(function(entry,idx){return entry!==undefined&&i!==idx});newMap=newList.toKeyedSeq().map(function(entry){return entry[0]}).flip().toMap();if(omap.__ownerID){newMap.__ownerID=newList.__ownerID=omap.__ownerID}}else{newMap=map.remove(k);newList=i===list.size-1?list.pop():list.set(i,undefined)}}else{if(has){if(v===list.get(i)[1]){return omap}newMap=map;newList=list.set(i,[k,v])}else{newMap=map.set(k,list.size);newList=list.set(list.size,[k,v])}}if(omap.__ownerID){omap.size=newMap.size;omap._map=newMap;omap._list=newList;omap.__hash=undefined;return omap}return makeOrderedMap(newMap,newList)}createClass(Stack,IndexedCollection);function Stack(value){return value===null||value===undefined?emptyStack():isStack(value)?value:emptyStack().unshiftAll(value)}Stack.of=function(){return this(arguments)};Stack.prototype.toString=function(){return this.__toString("Stack [","]")};Stack.prototype.get=function(index,notSetValue){var head=this._head;index=wrapIndex(this,index);while(head&&index--){head=head.next}return head?head.value:notSetValue};Stack.prototype.peek=function(){return this._head&&this._head.value};Stack.prototype.push=function(){if(arguments.length===0){return this}var newSize=this.size+arguments.length;var head=this._head;for(var ii=arguments.length-1;ii>=0;ii--){head={value:arguments[ii],next:head}}if(this.__ownerID){this.size=newSize;this._head=head;this.__hash=undefined;this.__altered=true;return this}return makeStack(newSize,head)};Stack.prototype.pushAll=function(iter){iter=IndexedIterable(iter);if(iter.size===0){return this}assertNotInfinite(iter.size);var newSize=this.size;var head=this._head;iter.reverse().forEach(function(value){newSize++;head={value:value,next:head}});if(this.__ownerID){this.size=newSize;this._head=head;this.__hash=undefined;this.__altered=true;return this}return makeStack(newSize,head)};Stack.prototype.pop=function(){return this.slice(1)};Stack.prototype.unshift=function(){return this.push.apply(this,arguments)};Stack.prototype.unshiftAll=function(iter){return this.pushAll(iter)};Stack.prototype.shift=function(){return this.pop.apply(this,arguments)};Stack.prototype.clear=function(){if(this.size===0){return this}if(this.__ownerID){this.size=0;this._head=undefined;this.__hash=undefined;this.__altered=true;return this}return emptyStack()};Stack.prototype.slice=function(begin,end){if(wholeSlice(begin,end,this.size)){return this}var resolvedBegin=resolveBegin(begin,this.size);var resolvedEnd=resolveEnd(end,this.size);if(resolvedEnd!==this.size){return IndexedCollection.prototype.slice.call(this,begin,end)}var newSize=this.size-resolvedBegin;var head=this._head;while(resolvedBegin--){head=head.next}if(this.__ownerID){this.size=newSize;this._head=head;this.__hash=undefined;this.__altered=true;return this}return makeStack(newSize,head)};Stack.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}if(!ownerID){this.__ownerID=ownerID;this.__altered=false;return this}return makeStack(this.size,this._head,ownerID,this.__hash)};Stack.prototype.__iterate=function(fn,reverse){if(reverse){return this.reverse().__iterate(fn)}var iterations=0;var node=this._head;while(node){if(fn(node.value,iterations++,this)===false){break}node=node.next}return iterations};Stack.prototype.__iterator=function(type,reverse){if(reverse){return this.reverse().__iterator(type)}var iterations=0;var node=this._head;return new src_Iterator__Iterator(function(){if(node){var value=node.value;node=node.next;return iteratorValue(type,iterations++,value)}return iteratorDone()})};function isStack(maybeStack){return!!(maybeStack&&maybeStack[IS_STACK_SENTINEL])}Stack.isStack=isStack;var IS_STACK_SENTINEL="@@__IMMUTABLE_STACK__@@";var StackPrototype=Stack.prototype;StackPrototype[IS_STACK_SENTINEL]=true;StackPrototype.withMutations=MapPrototype.withMutations;StackPrototype.asMutable=MapPrototype.asMutable;StackPrototype.asImmutable=MapPrototype.asImmutable;StackPrototype.wasAltered=MapPrototype.wasAltered;function makeStack(size,head,ownerID,hash){var map=Object.create(StackPrototype);map.size=size;map._head=head;map.__ownerID=ownerID;map.__hash=hash;map.__altered=false;return map}var EMPTY_STACK;function emptyStack(){return EMPTY_STACK||(EMPTY_STACK=makeStack(0))}createClass(src_Set__Set,SetCollection);function src_Set__Set(value){return value===null||value===undefined?emptySet():isSet(value)?value:emptySet().withMutations(function(set){var iter=SetIterable(value);assertNotInfinite(iter.size);iter.forEach(function(v){return set.add(v)})})}src_Set__Set.of=function(){return this(arguments)};src_Set__Set.fromKeys=function(value){return this(KeyedIterable(value).keySeq())};src_Set__Set.prototype.toString=function(){return this.__toString("Set {","}")};src_Set__Set.prototype.has=function(value){return this._map.has(value)};src_Set__Set.prototype.add=function(value){return updateSet(this,this._map.set(value,true))};src_Set__Set.prototype.remove=function(value){return updateSet(this,this._map.remove(value))};src_Set__Set.prototype.clear=function(){return updateSet(this,this._map.clear())};src_Set__Set.prototype.union=function(){var iters=SLICE$0.call(arguments,0);iters=iters.filter(function(x){return x.size!==0});if(iters.length===0){return this}if(this.size===0&&!this.__ownerID&&iters.length===1){return this.constructor(iters[0])}return this.withMutations(function(set){for(var ii=0;ii<iters.length;ii++){SetIterable(iters[ii]).forEach(function(value){return set.add(value)})}})};src_Set__Set.prototype.intersect=function(){var iters=SLICE$0.call(arguments,0);if(iters.length===0){return this}iters=iters.map(function(iter){return SetIterable(iter)});var originalSet=this;return this.withMutations(function(set){originalSet.forEach(function(value){if(!iters.every(function(iter){return iter.includes(value)})){set.remove(value)}})})};src_Set__Set.prototype.subtract=function(){var iters=SLICE$0.call(arguments,0);if(iters.length===0){return this}iters=iters.map(function(iter){return SetIterable(iter)});var originalSet=this;return this.withMutations(function(set){originalSet.forEach(function(value){if(iters.some(function(iter){return iter.includes(value)})){set.remove(value)}})})};src_Set__Set.prototype.merge=function(){return this.union.apply(this,arguments)};src_Set__Set.prototype.mergeWith=function(merger){var iters=SLICE$0.call(arguments,1);return this.union.apply(this,iters)};src_Set__Set.prototype.sort=function(comparator){return OrderedSet(sortFactory(this,comparator))};src_Set__Set.prototype.sortBy=function(mapper,comparator){return OrderedSet(sortFactory(this,comparator,mapper))};src_Set__Set.prototype.wasAltered=function(){return this._map.wasAltered()};src_Set__Set.prototype.__iterate=function(fn,reverse){var this$0=this;return this._map.__iterate(function(_,k){return fn(k,k,this$0)},reverse)};src_Set__Set.prototype.__iterator=function(type,reverse){return this._map.map(function(_,k){return k}).__iterator(type,reverse)};src_Set__Set.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;return this}return this.__make(newMap,ownerID)};function isSet(maybeSet){return!!(maybeSet&&maybeSet[IS_SET_SENTINEL])}src_Set__Set.isSet=isSet;var IS_SET_SENTINEL="@@__IMMUTABLE_SET__@@";var SetPrototype=src_Set__Set.prototype;SetPrototype[IS_SET_SENTINEL]=true;SetPrototype[DELETE]=SetPrototype.remove;SetPrototype.mergeDeep=SetPrototype.merge;SetPrototype.mergeDeepWith=SetPrototype.mergeWith;SetPrototype.withMutations=MapPrototype.withMutations;SetPrototype.asMutable=MapPrototype.asMutable;SetPrototype.asImmutable=MapPrototype.asImmutable;SetPrototype.__empty=emptySet;SetPrototype.__make=makeSet;function updateSet(set,newMap){if(set.__ownerID){set.size=newMap.size;set._map=newMap;return set}return newMap===set._map?set:newMap.size===0?set.__empty():set.__make(newMap)}function makeSet(map,ownerID){var set=Object.create(SetPrototype);set.size=map?map.size:0;set._map=map;set.__ownerID=ownerID;return set}var EMPTY_SET;function emptySet(){return EMPTY_SET||(EMPTY_SET=makeSet(emptyMap()))}createClass(OrderedSet,src_Set__Set);function OrderedSet(value){return value===null||value===undefined?emptyOrderedSet():isOrderedSet(value)?value:emptyOrderedSet().withMutations(function(set){var iter=SetIterable(value);assertNotInfinite(iter.size);iter.forEach(function(v){return set.add(v)})})}OrderedSet.of=function(){return this(arguments)};OrderedSet.fromKeys=function(value){return this(KeyedIterable(value).keySeq())};OrderedSet.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function isOrderedSet(maybeOrderedSet){return isSet(maybeOrderedSet)&&isOrdered(maybeOrderedSet)}OrderedSet.isOrderedSet=isOrderedSet;var OrderedSetPrototype=OrderedSet.prototype;OrderedSetPrototype[IS_ORDERED_SENTINEL]=true;OrderedSetPrototype.__empty=emptyOrderedSet;OrderedSetPrototype.__make=makeOrderedSet;function makeOrderedSet(map,ownerID){var set=Object.create(OrderedSetPrototype);set.size=map?map.size:0;set._map=map;set.__ownerID=ownerID;return set}var EMPTY_ORDERED_SET;function emptyOrderedSet(){return EMPTY_ORDERED_SET||(EMPTY_ORDERED_SET=makeOrderedSet(emptyOrderedMap()))}createClass(Record,KeyedCollection);function Record(defaultValues,name){var hasInitialized;var RecordType=function Record(values){if(values instanceof RecordType){return values}if(!(this instanceof RecordType)){return new RecordType(values)}if(!hasInitialized){hasInitialized=true;var keys=Object.keys(defaultValues);setProps(RecordTypePrototype,keys);RecordTypePrototype.size=keys.length;RecordTypePrototype._name=name;RecordTypePrototype._keys=keys;RecordTypePrototype._defaultValues=defaultValues}this._map=src_Map__Map(values)};var RecordTypePrototype=RecordType.prototype=Object.create(RecordPrototype);RecordTypePrototype.constructor=RecordType;return RecordType}Record.prototype.toString=function(){return this.__toString(recordName(this)+" {","}")};Record.prototype.has=function(k){return this._defaultValues.hasOwnProperty(k)};Record.prototype.get=function(k,notSetValue){if(!this.has(k)){return notSetValue}var defaultVal=this._defaultValues[k];return this._map?this._map.get(k,defaultVal):defaultVal};Record.prototype.clear=function(){if(this.__ownerID){this._map&&this._map.clear();return this}var RecordType=this.constructor;return RecordType._empty||(RecordType._empty=makeRecord(this,emptyMap()))};Record.prototype.set=function(k,v){if(!this.has(k)){throw new Error('Cannot set unknown key "'+k+'" on '+recordName(this))}var newMap=this._map&&this._map.set(k,v);if(this.__ownerID||newMap===this._map){return this}return makeRecord(this,newMap)};Record.prototype.remove=function(k){if(!this.has(k)){return this}var newMap=this._map&&this._map.remove(k);if(this.__ownerID||newMap===this._map){return this}return makeRecord(this,newMap)};Record.prototype.wasAltered=function(){return this._map.wasAltered()};Record.prototype.__iterator=function(type,reverse){var this$0=this;return KeyedIterable(this._defaultValues).map(function(_,k){return this$0.get(k)}).__iterator(type,reverse)};Record.prototype.__iterate=function(fn,reverse){var this$0=this;return KeyedIterable(this._defaultValues).map(function(_,k){return this$0.get(k)}).__iterate(fn,reverse)};Record.prototype.__ensureOwner=function(ownerID){if(ownerID===this.__ownerID){return this}var newMap=this._map&&this._map.__ensureOwner(ownerID);if(!ownerID){this.__ownerID=ownerID;this._map=newMap;return this}return makeRecord(this,newMap,ownerID)};var RecordPrototype=Record.prototype;RecordPrototype[DELETE]=RecordPrototype.remove;RecordPrototype.deleteIn=RecordPrototype.removeIn=MapPrototype.removeIn;RecordPrototype.merge=MapPrototype.merge;RecordPrototype.mergeWith=MapPrototype.mergeWith;RecordPrototype.mergeIn=MapPrototype.mergeIn;RecordPrototype.mergeDeep=MapPrototype.mergeDeep;RecordPrototype.mergeDeepWith=MapPrototype.mergeDeepWith;RecordPrototype.mergeDeepIn=MapPrototype.mergeDeepIn;RecordPrototype.setIn=MapPrototype.setIn;RecordPrototype.update=MapPrototype.update;RecordPrototype.updateIn=MapPrototype.updateIn;RecordPrototype.withMutations=MapPrototype.withMutations;RecordPrototype.asMutable=MapPrototype.asMutable;RecordPrototype.asImmutable=MapPrototype.asImmutable;function makeRecord(likeRecord,map,ownerID){var record=Object.create(Object.getPrototypeOf(likeRecord));record._map=map;record.__ownerID=ownerID;return record}function recordName(record){return record._name||record.constructor.name||"Record"}function setProps(prototype,names){try{names.forEach(setProp.bind(undefined,prototype))}catch(error){}}function setProp(prototype,name){Object.defineProperty(prototype,name,{get:function(){return this.get(name)},set:function(value){invariant(this.__ownerID,"Cannot set on an immutable record.");this.set(name,value)}})}function deepEqual(a,b){if(a===b){return true}if(!isIterable(b)||a.size!==undefined&&b.size!==undefined&&a.size!==b.size||a.__hash!==undefined&&b.__hash!==undefined&&a.__hash!==b.__hash||isKeyed(a)!==isKeyed(b)||isIndexed(a)!==isIndexed(b)||isOrdered(a)!==isOrdered(b)){return false}if(a.size===0&&b.size===0){return true}var notAssociative=!isAssociative(a);if(isOrdered(a)){var entries=a.entries();return b.every(function(v,k){var entry=entries.next().value;return entry&&is(entry[1],v)&&(notAssociative||is(entry[0],k))})&&entries.next().done}var flipped=false;if(a.size===undefined){if(b.size===undefined){if(typeof a.cacheResult==="function"){a.cacheResult()}}else{flipped=true;var _=a;a=b;b=_}}var allEqual=true;var bSize=b.__iterate(function(v,k){if(notAssociative?!a.has(v):flipped?!is(v,a.get(k,NOT_SET)):!is(a.get(k,NOT_SET),v)){allEqual=false;return false}});return allEqual&&a.size===bSize}createClass(Range,IndexedSeq);function Range(start,end,step){if(!(this instanceof Range)){return new Range(start,end,step)}invariant(step!==0,"Cannot step a Range by 0");start=start||0;if(end===undefined){end=Infinity}step=step===undefined?1:Math.abs(step);if(end<start){step=-step}this._start=start;this._end=end;this._step=step;this.size=Math.max(0,Math.ceil((end-start)/step-1)+1);if(this.size===0){if(EMPTY_RANGE){return EMPTY_RANGE}EMPTY_RANGE=this}}Range.prototype.toString=function(){if(this.size===0){return"Range []"}return"Range [ "+this._start+"..."+this._end+(this._step>1?" by "+this._step:"")+" ]"};Range.prototype.get=function(index,notSetValue){return this.has(index)?this._start+wrapIndex(this,index)*this._step:notSetValue};Range.prototype.includes=function(searchValue){var possibleIndex=(searchValue-this._start)/this._step;return possibleIndex>=0&&possibleIndex<this.size&&possibleIndex===Math.floor(possibleIndex)};Range.prototype.slice=function(begin,end){if(wholeSlice(begin,end,this.size)){return this}begin=resolveBegin(begin,this.size);end=resolveEnd(end,this.size);if(end<=begin){return new Range(0,0)}return new Range(this.get(begin,this._end),this.get(end,this._end),this._step)};Range.prototype.indexOf=function(searchValue){var offsetValue=searchValue-this._start;if(offsetValue%this._step===0){var index=offsetValue/this._step;if(index>=0&&index<this.size){return index}}return-1};Range.prototype.lastIndexOf=function(searchValue){return this.indexOf(searchValue)};Range.prototype.__iterate=function(fn,reverse){var maxIndex=this.size-1;var step=this._step;var value=reverse?this._start+maxIndex*step:this._start;for(var ii=0;ii<=maxIndex;ii++){if(fn(value,ii,this)===false){return ii+1}value+=reverse?-step:step}return ii};Range.prototype.__iterator=function(type,reverse){var maxIndex=this.size-1;var step=this._step;var value=reverse?this._start+maxIndex*step:this._start;var ii=0;return new src_Iterator__Iterator(function(){var v=value;value+=reverse?-step:step;return ii>maxIndex?iteratorDone():iteratorValue(type,ii++,v)})};Range.prototype.equals=function(other){return other instanceof Range?this._start===other._start&&this._end===other._end&&this._step===other._step:deepEqual(this,other)};var EMPTY_RANGE;createClass(Repeat,IndexedSeq);function Repeat(value,times){if(!(this instanceof Repeat)){return new Repeat(value,times)}this._value=value;this.size=times===undefined?Infinity:Math.max(0,times);if(this.size===0){if(EMPTY_REPEAT){return EMPTY_REPEAT}EMPTY_REPEAT=this}}Repeat.prototype.toString=function(){if(this.size===0){return"Repeat []"}return"Repeat [ "+this._value+" "+this.size+" times ]"};Repeat.prototype.get=function(index,notSetValue){return this.has(index)?this._value:notSetValue};Repeat.prototype.includes=function(searchValue){return is(this._value,searchValue)};Repeat.prototype.slice=function(begin,end){var size=this.size;return wholeSlice(begin,end,size)?this:new Repeat(this._value,resolveEnd(end,size)-resolveBegin(begin,size))};Repeat.prototype.reverse=function(){return this};Repeat.prototype.indexOf=function(searchValue){if(is(this._value,searchValue)){return 0}return-1};Repeat.prototype.lastIndexOf=function(searchValue){if(is(this._value,searchValue)){return this.size}return-1};Repeat.prototype.__iterate=function(fn,reverse){for(var ii=0;ii<this.size;ii++){if(fn(this._value,ii,this)===false){return ii+1}}return ii};Repeat.prototype.__iterator=function(type,reverse){var this$0=this;var ii=0;return new src_Iterator__Iterator(function(){return ii<this$0.size?iteratorValue(type,ii++,this$0._value):iteratorDone()})};Repeat.prototype.equals=function(other){return other instanceof Repeat?is(this._value,other._value):deepEqual(other)};var EMPTY_REPEAT;function mixin(ctor,methods){var keyCopier=function(key){ctor.prototype[key]=methods[key]};Object.keys(methods).forEach(keyCopier);Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(methods).forEach(keyCopier);return ctor}Iterable.Iterator=src_Iterator__Iterator;mixin(Iterable,{toArray:function(){assertNotInfinite(this.size);var array=new Array(this.size||0);this.valueSeq().__iterate(function(v,i){array[i]=v});return array},toIndexedSeq:function(){return new ToIndexedSequence(this)},toJS:function(){return this.toSeq().map(function(value){return value&&typeof value.toJS==="function"?value.toJS():value}).__toJS()},toJSON:function(){return this.toSeq().map(function(value){return value&&typeof value.toJSON==="function"?value.toJSON():value}).__toJS()},toKeyedSeq:function(){return new ToKeyedSequence(this,true)},toMap:function(){return src_Map__Map(this.toKeyedSeq())},toObject:function(){assertNotInfinite(this.size);var object={};this.__iterate(function(v,k){object[k]=v});return object},toOrderedMap:function(){return OrderedMap(this.toKeyedSeq())},toOrderedSet:function(){return OrderedSet(isKeyed(this)?this.valueSeq():this)},toSet:function(){return src_Set__Set(isKeyed(this)?this.valueSeq():this)},toSetSeq:function(){return new ToSetSequence(this)},toSeq:function(){return isIndexed(this)?this.toIndexedSeq():isKeyed(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Stack(isKeyed(this)?this.valueSeq():this)},toList:function(){return List(isKeyed(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(head,tail){if(this.size===0){return head+tail}return head+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+tail},concat:function(){var values=SLICE$0.call(arguments,0);return reify(this,concatFactory(this,values))},contains:function(searchValue){return this.includes(searchValue)},includes:function(searchValue){return this.some(function(value){return is(value,searchValue)})},entries:function(){return this.__iterator(ITERATE_ENTRIES)},every:function(predicate,context){assertNotInfinite(this.size);var returnValue=true;this.__iterate(function(v,k,c){if(!predicate.call(context,v,k,c)){returnValue=false;return false}});return returnValue},filter:function(predicate,context){return reify(this,filterFactory(this,predicate,context,true))},find:function(predicate,context,notSetValue){var entry=this.findEntry(predicate,context);return entry?entry[1]:notSetValue},findEntry:function(predicate,context){var found;this.__iterate(function(v,k,c){if(predicate.call(context,v,k,c)){found=[k,v];return false}});return found},findLastEntry:function(predicate,context){return this.toSeq().reverse().findEntry(predicate,context)},forEach:function(sideEffect,context){assertNotInfinite(this.size);return this.__iterate(context?sideEffect.bind(context):sideEffect)},join:function(separator){assertNotInfinite(this.size);separator=separator!==undefined?""+separator:",";var joined="";var isFirst=true;this.__iterate(function(v){isFirst?isFirst=false:joined+=separator;joined+=v!==null&&v!==undefined?v.toString():""});return joined},keys:function(){return this.__iterator(ITERATE_KEYS)},map:function(mapper,context){return reify(this,mapFactory(this,mapper,context))},reduce:function(reducer,initialReduction,context){ | |
assertNotInfinite(this.size);var reduction;var useFirst;if(arguments.length<2){useFirst=true}else{reduction=initialReduction}this.__iterate(function(v,k,c){if(useFirst){useFirst=false;reduction=v}else{reduction=reducer.call(context,reduction,v,k,c)}});return reduction},reduceRight:function(reducer,initialReduction,context){var reversed=this.toKeyedSeq().reverse();return reversed.reduce.apply(reversed,arguments)},reverse:function(){return reify(this,reverseFactory(this,true))},slice:function(begin,end){return reify(this,sliceFactory(this,begin,end,true))},some:function(predicate,context){return!this.every(not(predicate),context)},sort:function(comparator){return reify(this,sortFactory(this,comparator))},values:function(){return this.__iterator(ITERATE_VALUES)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==undefined?this.size===0:!this.some(function(){return true})},count:function(predicate,context){return ensureSize(predicate?this.toSeq().filter(predicate,context):this)},countBy:function(grouper,context){return countByFactory(this,grouper,context)},equals:function(other){return deepEqual(this,other)},entrySeq:function(){var iterable=this;if(iterable._cache){return new ArraySeq(iterable._cache)}var entriesSequence=iterable.toSeq().map(entryMapper).toIndexedSeq();entriesSequence.fromEntrySeq=function(){return iterable.toSeq()};return entriesSequence},filterNot:function(predicate,context){return this.filter(not(predicate),context)},findLast:function(predicate,context,notSetValue){return this.toKeyedSeq().reverse().find(predicate,context,notSetValue)},first:function(){return this.find(returnTrue)},flatMap:function(mapper,context){return reify(this,flatMapFactory(this,mapper,context))},flatten:function(depth){return reify(this,flattenFactory(this,depth,true))},fromEntrySeq:function(){return new FromEntriesSequence(this)},get:function(searchKey,notSetValue){return this.find(function(_,key){return is(key,searchKey)},undefined,notSetValue)},getIn:function(searchKeyPath,notSetValue){var nested=this;var iter=forceIterator(searchKeyPath);var step;while(!(step=iter.next()).done){var key=step.value;nested=nested&&nested.get?nested.get(key,NOT_SET):NOT_SET;if(nested===NOT_SET){return notSetValue}}return nested},groupBy:function(grouper,context){return groupByFactory(this,grouper,context)},has:function(searchKey){return this.get(searchKey,NOT_SET)!==NOT_SET},hasIn:function(searchKeyPath){return this.getIn(searchKeyPath,NOT_SET)!==NOT_SET},isSubset:function(iter){iter=typeof iter.includes==="function"?iter:Iterable(iter);return this.every(function(value){return iter.includes(value)})},isSuperset:function(iter){iter=typeof iter.isSubset==="function"?iter:Iterable(iter);return iter.isSubset(this)},keySeq:function(){return this.toSeq().map(keyMapper).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},max:function(comparator){return maxFactory(this,comparator)},maxBy:function(mapper,comparator){return maxFactory(this,comparator,mapper)},min:function(comparator){return maxFactory(this,comparator?neg(comparator):defaultNegComparator)},minBy:function(mapper,comparator){return maxFactory(this,comparator?neg(comparator):defaultNegComparator,mapper)},rest:function(){return this.slice(1)},skip:function(amount){return this.slice(Math.max(0,amount))},skipLast:function(amount){return reify(this,this.toSeq().reverse().skip(amount).reverse())},skipWhile:function(predicate,context){return reify(this,skipWhileFactory(this,predicate,context,true))},skipUntil:function(predicate,context){return this.skipWhile(not(predicate),context)},sortBy:function(mapper,comparator){return reify(this,sortFactory(this,comparator,mapper))},take:function(amount){return this.slice(0,Math.max(0,amount))},takeLast:function(amount){return reify(this,this.toSeq().reverse().take(amount).reverse())},takeWhile:function(predicate,context){return reify(this,takeWhileFactory(this,predicate,context))},takeUntil:function(predicate,context){return this.takeWhile(not(predicate),context)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=hashIterable(this))}});var IterablePrototype=Iterable.prototype;IterablePrototype[IS_ITERABLE_SENTINEL]=true;IterablePrototype[ITERATOR_SYMBOL]=IterablePrototype.values;IterablePrototype.__toJS=IterablePrototype.toArray;IterablePrototype.__toStringMapper=quoteString;IterablePrototype.inspect=IterablePrototype.toSource=function(){return this.toString()};IterablePrototype.chain=IterablePrototype.flatMap;(function(){try{Object.defineProperty(IterablePrototype,"length",{get:function(){if(!Iterable.noLengthWarning){var stack;try{throw new Error}catch(error){stack=error.stack}if(stack.indexOf("_wrapObject")===-1){console&&console.warn&&console.warn("iterable.length has been deprecated, "+"use iterable.size or iterable.count(). "+"This warning will become a silent error in a future version. "+stack);return this.size}}}})}catch(e){}})();mixin(KeyedIterable,{flip:function(){return reify(this,flipFactory(this))},findKey:function(predicate,context){var entry=this.findEntry(predicate,context);return entry&&entry[0]},findLastKey:function(predicate,context){return this.toSeq().reverse().findKey(predicate,context)},keyOf:function(searchValue){return this.findKey(function(value){return is(value,searchValue)})},lastKeyOf:function(searchValue){return this.findLastKey(function(value){return is(value,searchValue)})},mapEntries:function(mapper,context){var this$0=this;var iterations=0;return reify(this,this.toSeq().map(function(v,k){return mapper.call(context,[k,v],iterations++,this$0)}).fromEntrySeq())},mapKeys:function(mapper,context){var this$0=this;return reify(this,this.toSeq().flip().map(function(k,v){return mapper.call(context,k,v,this$0)}).flip())}});var KeyedIterablePrototype=KeyedIterable.prototype;KeyedIterablePrototype[IS_KEYED_SENTINEL]=true;KeyedIterablePrototype[ITERATOR_SYMBOL]=IterablePrototype.entries;KeyedIterablePrototype.__toJS=IterablePrototype.toObject;KeyedIterablePrototype.__toStringMapper=function(v,k){return JSON.stringify(k)+": "+quoteString(v)};mixin(IndexedIterable,{toKeyedSeq:function(){return new ToKeyedSequence(this,false)},filter:function(predicate,context){return reify(this,filterFactory(this,predicate,context,false))},findIndex:function(predicate,context){var entry=this.findEntry(predicate,context);return entry?entry[0]:-1},indexOf:function(searchValue){var key=this.toKeyedSeq().keyOf(searchValue);return key===undefined?-1:key},lastIndexOf:function(searchValue){return this.toSeq().reverse().indexOf(searchValue)},reverse:function(){return reify(this,reverseFactory(this,false))},slice:function(begin,end){return reify(this,sliceFactory(this,begin,end,false))},splice:function(index,removeNum){var numArgs=arguments.length;removeNum=Math.max(removeNum|0,0);if(numArgs===0||numArgs===2&&!removeNum){return this}index=resolveBegin(index,this.size);var spliced=this.slice(0,index);return reify(this,numArgs===1?spliced:spliced.concat(arrCopy(arguments,2),this.slice(index+removeNum)))},findLastIndex:function(predicate,context){var key=this.toKeyedSeq().findLastKey(predicate,context);return key===undefined?-1:key},first:function(){return this.get(0)},flatten:function(depth){return reify(this,flattenFactory(this,depth,false))},get:function(index,notSetValue){index=wrapIndex(this,index);return index<0||(this.size===Infinity||this.size!==undefined&&index>this.size)?notSetValue:this.find(function(_,key){return key===index},undefined,notSetValue)},has:function(index){index=wrapIndex(this,index);return index>=0&&(this.size!==undefined?this.size===Infinity||index<this.size:this.indexOf(index)!==-1)},interpose:function(separator){return reify(this,interposeFactory(this,separator))},interleave:function(){var iterables=[this].concat(arrCopy(arguments));var zipped=zipWithFactory(this.toSeq(),IndexedSeq.of,iterables);var interleaved=zipped.flatten(true);if(zipped.size){interleaved.size=zipped.size*iterables.length}return reify(this,interleaved)},last:function(){return this.get(-1)},skipWhile:function(predicate,context){return reify(this,skipWhileFactory(this,predicate,context,false))},zip:function(){var iterables=[this].concat(arrCopy(arguments));return reify(this,zipWithFactory(this,defaultZipper,iterables))},zipWith:function(zipper){var iterables=arrCopy(arguments);iterables[0]=this;return reify(this,zipWithFactory(this,zipper,iterables))}});IndexedIterable.prototype[IS_INDEXED_SENTINEL]=true;IndexedIterable.prototype[IS_ORDERED_SENTINEL]=true;mixin(SetIterable,{get:function(value,notSetValue){return this.has(value)?value:notSetValue},includes:function(value){return this.has(value)},keySeq:function(){return this.valueSeq()}});SetIterable.prototype.has=IterablePrototype.includes;mixin(KeyedSeq,KeyedIterable.prototype);mixin(IndexedSeq,IndexedIterable.prototype);mixin(SetSeq,SetIterable.prototype);mixin(KeyedCollection,KeyedIterable.prototype);mixin(IndexedCollection,IndexedIterable.prototype);mixin(SetCollection,SetIterable.prototype);function keyMapper(v,k){return k}function entryMapper(v,k){return[k,v]}function not(predicate){return function(){return!predicate.apply(this,arguments)}}function neg(predicate){return function(){return-predicate.apply(this,arguments)}}function quoteString(value){return typeof value==="string"?JSON.stringify(value):value}function defaultZipper(){return arrCopy(arguments)}function defaultNegComparator(a,b){return a<b?1:a>b?-1:0}function hashIterable(iterable){if(iterable.size===Infinity){return 0}var ordered=isOrdered(iterable);var keyed=isKeyed(iterable);var h=ordered?1:0;var size=iterable.__iterate(keyed?ordered?function(v,k){h=31*h+hashMerge(hash(v),hash(k))|0}:function(v,k){h=h+hashMerge(hash(v),hash(k))|0}:ordered?function(v){h=31*h+hash(v)|0}:function(v){h=h+hash(v)|0});return murmurHashOfSize(size,h)}function murmurHashOfSize(size,h){h=src_Math__imul(h,3432918353);h=src_Math__imul(h<<15|h>>>-15,461845907);h=src_Math__imul(h<<13|h>>>-13,5);h=(h+3864292196|0)^size;h=src_Math__imul(h^h>>>16,2246822507);h=src_Math__imul(h^h>>>13,3266489909);h=smi(h^h>>>16);return h}function hashMerge(a,b){return a^b+2654435769+(a<<6)+(a>>2)|0}var Immutable={Iterable:Iterable,Seq:Seq,Collection:Collection,Map:src_Map__Map,OrderedMap:OrderedMap,List:List,Stack:Stack,Set:src_Set__Set,OrderedSet:OrderedSet,Record:Record,Range:Range,Repeat:Repeat,is:is,fromJS:fromJS};return Immutable})},{}],4:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],5:[function(require,module,exports){"use strict";var Immutable=require("immutable");var Cursor=require("immutable/contrib/cursor");var EventEmitter=require("eventemitter3").EventEmitter;var inherits=require("inherits");var utils=require("./utils");function Structure(options){var self=this;options=options||{};if(!(this instanceof Structure)){return new Structure(options)}this.key=options.key||utils.generateRandomKey();this.current=options.data;if(!isImmutableStructure(this.current)||!this.current){this.current=Immutable.fromJS(this.current||{})}if(!!options.history){this.history=Immutable.List.of(this.current);this._currentRevision=0}this._pathListeners=[];this.on("swap",function(newData,oldData,keyPath){listListenerMatching(self._pathListeners,pathString(keyPath)).forEach(function(fns){fns.forEach(function(fn){if(typeof fn!=="function")return;fn(newData,oldData,keyPath)})})});EventEmitter.call(this,arguments)}inherits(Structure,EventEmitter);module.exports=Structure;Structure.prototype.cursor=function(path){var self=this;path=path||[];if(!this.current){throw new Error("No structure loaded.")}var changeListener=function(newRoot,oldRoot,path){if(self.current===oldRoot){self.current=newRoot}else if(!hasIn(newRoot,path)){self.current=self.current.removeIn(path)}else{self.current=self.current.setIn(path,newRoot.getIn(path))}return self.current};changeListener=handleHistory(this,changeListener);changeListener=handleSwap(this,changeListener);changeListener=handlePersisting(this,changeListener);return Cursor.from(self.current,path,changeListener)};Structure.prototype.reference=function(path){if(isCursor(path)&&path._keyPath){path=path._keyPath}var self=this,pathId=pathString(path);var listenerNs=self._pathListeners[pathId];var cursor=this.cursor(path);var changeListener=function(newRoot,oldRoot,changedPath){cursor=self.cursor(path)};var referenceListeners=[changeListener];this._pathListeners[pathId]=!listenerNs?referenceListeners:listenerNs.concat(changeListener);return{observe:function(eventName,newFn){if(typeof eventName==="function"){newFn=eventName;eventName=void 0}if(this._dead||typeof newFn!=="function")return;if(eventName&&eventName!=="swap"){newFn=onlyOnEvent(eventName,newFn)}self._pathListeners[pathId]=self._pathListeners[pathId].concat(newFn);referenceListeners=referenceListeners.concat(newFn);return function unobserve(){var fnIndex=self._pathListeners[pathId].indexOf(newFn);var localListenerIndex=referenceListeners.indexOf(newFn);if(referenceListeners[localListenerIndex]===newFn){referenceListeners.splice(localListenerIndex,1)}if(!self._pathListeners[pathId])return;if(self._pathListeners[pathId][fnIndex]!==newFn)return;self._pathListeners[pathId].splice(fnIndex,1)}},cursor:function(subPath){if(subPath)return cursor.cursor(subPath);return cursor},unobserveAll:function(){removeAllListenersBut(self,pathId,referenceListeners,changeListener);referenceListeners=[changeListener]},destroy:function(){removeAllListenersBut(self,pathId,referenceListeners);referenceListeners=void 0;cursor=void 0;this._dead=true;this.observe=void 0;this.unobserveAll=void 0;this.cursor=void 0;this.destroy=void 0}}};Structure.prototype.forceHasSwapped=function(newData,oldData,keyPath){this.emit("swap",newData||this.current,oldData,keyPath);possiblyEmitAnimationFrameEvent(this,newData||this.current,oldData,keyPath)};Structure.prototype.undo=function(back){this._currentRevision-=back||1;if(this._currentRevision<0){this._currentRevision=0}this.current=this.history.get(this._currentRevision);return this.current};Structure.prototype.redo=function(head){this._currentRevision+=head||1;if(this._currentRevision>this.history.count()-1){this._currentRevision=this.history.count()-1}this.current=this.history.get(this._currentRevision);return this.current};Structure.prototype.undoUntil=function(structure){this._currentRevision=this.history.indexOf(structure);this.current=structure;return structure};function handleHistory(emitter,fn){return function(newData,oldData,path){var newStructure=fn.apply(fn,arguments);if(!emitter.history||newData===oldData)return newStructure;emitter.history=emitter.history.take(++emitter._currentRevision).push(emitter.current);return newStructure}}var possiblyEmitAnimationFrameEvent=function(){var queuedChange=false;if(typeof requestAnimationFrame!=="function"){return function(){}}return function requestAnimationFrameEmitter(emitter,newStructure,oldData){if(queuedChange)return;queuedChange=true;requestAnimationFrame(function(){queuedChange=false;emitter.emit("next-animation-frame",newStructure,oldData)})}}();function handleSwap(emitter,fn){return function(newData,oldData,keyPath){var newStructure=fn.apply(fn,arguments);if(newData===oldData)return newStructure;emitter.emit("swap",newStructure,oldData,keyPath);possiblyEmitAnimationFrameEvent(emitter,newStructure,oldData,keyPath);return newStructure}}function handlePersisting(emitter,fn){return function(newData,oldData,path){var newStructure=fn.apply(fn,arguments);if(newData===oldData)return newStructure;var info=analyze(newData,oldData,path);if(info.eventName){emitter.emit.apply(emitter,[info.eventName].concat(info.args))}return newStructure}}function removeAllListenersBut(self,pathId,listeners,except){if(!listeners)return;listeners.forEach(function(fn){if(except&&fn===except)return;var index=self._pathListeners[pathId].indexOf(fn);self._pathListeners[pathId].splice(index,1)})}function analyze(newData,oldData,path){var oldObject=oldData&&oldData.getIn(path);var newObject=newData&&newData.getIn(path);var inOld=oldData&&hasIn(oldData,path);var inNew=newData&&hasIn(newData,path);var args,eventName;if(inOld&&!inNew){eventName="delete";args=[path,oldObject]}else if(inOld&&inNew){eventName="change";args=[path,newObject,oldObject]}else if(!inOld&&inNew){eventName="add";args=[path,newObject]}return{eventName:eventName,args:args}}var NOT_SET={};function hasIn(cursor,path){if(cursor.hasIn)return cursor.hasIn(path);return cursor.getIn(path,NOT_SET)!==NOT_SET}function pathString(path){var topLevel="global";if(!path||!path.length)return topLevel;return[topLevel].concat(path).join("|")}function listListenerMatching(listeners,basePath){var newListeners=[];for(var key in listeners){if(!listeners.hasOwnProperty(key))continue;if(basePath.indexOf(key)!==0)continue;newListeners.push(listeners[key])}return newListeners}function onlyOnEvent(eventName,fn){return function(newData,oldData,keyPath){var info=analyze(newData,oldData,keyPath);if(info.eventName!==eventName)return;return fn(newData,oldData,keyPath)}}function isCursor(potential){return potential&&typeof potential.deref==="function"}function isImmutableStructure(data){return immutableSafeCheck("Iterable","isIterable",data)||immutableSafeCheck("Seq","isSeq",data)||immutableSafeCheck("Map","isMap",data)||immutableSafeCheck("OrderedMap","isOrderedMap",data)||immutableSafeCheck("List","isList",data)||immutableSafeCheck("Stack","isStack",data)||immutableSafeCheck("Set","isSet",data)}function immutableSafeCheck(ns,method,data){return Immutable[ns]&&Immutable[ns][method]&&Immutable[ns][method](data)}},{"./utils":6,eventemitter3:1,immutable:3,"immutable/contrib/cursor":2,inherits:4}],6:[function(require,module,exports){"use strict";module.exports.generateRandomKey=function(len){len=len||10;return Math.random().toString(36).substring(2).substring(0,len)}},{}],immstruct:[function(require,module,exports){"use strict";var Structure=require("./src/structure");function Immstruct(){if(!(this instanceof Immstruct)){return new Immstruct}this.instances={}}Immstruct.prototype.get=function(key,data){return getInstance(this,{key:key,data:data})};Immstruct.prototype.clear=function(){this.instances={}};Immstruct.prototype.remove=function(key){return delete this.instances[key]};Immstruct.prototype.withHistory=function(key,data){return getInstance(this,{key:key,data:data,history:true})};var inst=new Immstruct;module.exports=function(key,data){return getInstance(inst,{key:key,data:data})};module.exports.withHistory=function(key,data){return getInstance(inst,{key:key,data:data,history:true})};module.exports.Structure=Structure;module.exports.Immstruct=Immstruct;module.exports.clear=inst.clear.bind(inst);module.exports.remove=inst.remove.bind(inst);Object.defineProperty(module.exports,"instances",{get:function(){return inst.instances},enumerable:true,configurable:true});function getInstance(obj,options){if(typeof options.key==="object"){options.data=options.key;options.key=void 0}if(options.key&&obj.instances[options.key]){return obj.instances[options.key]}var newInstance=new Structure(options);obj.instances[newInstance.key]=newInstance;return newInstance}},{"./src/structure":5}]},{},[]);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){},{}],2:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],3:[function(require,module,exports){var EvStore=require("ev-store");module.exports=addEvent;function addEvent(target,type,handler){var events=EvStore(target);var event=events[type];if(!event){events[type]=handler}else if(Array.isArray(event)){if(event.indexOf(handler)===-1){event.push(handler)}}else if(event!==handler){events[type]=[event,handler]}}},{"ev-store":7}],4:[function(require,module,exports){var globalDocument=require("global/document");var EvStore=require("ev-store");var createStore=require("weakmap-shim/create-store");var addEvent=require("./add-event.js");var removeEvent=require("./remove-event.js");var ProxyEvent=require("./proxy-event.js");var HANDLER_STORE=createStore();module.exports=DOMDelegator;function DOMDelegator(document){if(!(this instanceof DOMDelegator)){return new DOMDelegator(document)}document=document||globalDocument;this.target=document.documentElement;this.events={};this.rawEventListeners={};this.globalListeners={}}DOMDelegator.prototype.addEventListener=addEvent;DOMDelegator.prototype.removeEventListener=removeEvent;DOMDelegator.allocateHandle=function allocateHandle(func){var handle=new Handle;HANDLER_STORE(handle).func=func;return handle};DOMDelegator.transformHandle=function transformHandle(handle,broadcast){var func=HANDLER_STORE(handle).func;return this.allocateHandle(function(ev){broadcast(ev,func)})};DOMDelegator.prototype.addGlobalEventListener=function addGlobalEventListener(eventName,fn){var listeners=this.globalListeners[eventName]||[];if(listeners.indexOf(fn)===-1){listeners.push(fn)}this.globalListeners[eventName]=listeners};DOMDelegator.prototype.removeGlobalEventListener=function removeGlobalEventListener(eventName,fn){var listeners=this.globalListeners[eventName]||[];var index=listeners.indexOf(fn);if(index!==-1){listeners.splice(index,1)}};DOMDelegator.prototype.listenTo=function listenTo(eventName){if(!(eventName in this.events)){this.events[eventName]=0}this.events[eventName]++;if(this.events[eventName]!==1){return}var listener=this.rawEventListeners[eventName];if(!listener){listener=this.rawEventListeners[eventName]=createHandler(eventName,this)}this.target.addEventListener(eventName,listener,true)};DOMDelegator.prototype.unlistenTo=function unlistenTo(eventName){if(!(eventName in this.events)){this.events[eventName]=0}if(this.events[eventName]===0){throw new Error("already unlistened to event.")}this.events[eventName]--;if(this.events[eventName]!==0){return}var listener=this.rawEventListeners[eventName];if(!listener){throw new Error("dom-delegator#unlistenTo: cannot "+"unlisten to "+eventName)}this.target.removeEventListener(eventName,listener,true)};function createHandler(eventName,delegator){var globalListeners=delegator.globalListeners;var delegatorTarget=delegator.target;return handler;function handler(ev){var globalHandlers=globalListeners[eventName]||[];if(globalHandlers.length>0){var globalEvent=new ProxyEvent(ev);globalEvent.currentTarget=delegatorTarget;callListeners(globalHandlers,globalEvent)}findAndInvokeListeners(ev.target,ev,eventName)}}function findAndInvokeListeners(elem,ev,eventName){var listener=getListener(elem,eventName);if(listener&&listener.handlers.length>0){var listenerEvent=new ProxyEvent(ev);listenerEvent.currentTarget=listener.currentTarget;callListeners(listener.handlers,listenerEvent);if(listenerEvent._bubbles){var nextTarget=listener.currentTarget.parentNode;findAndInvokeListeners(nextTarget,ev,eventName)}}}function getListener(target,type){if(target===null||typeof target==="undefined"){return null}var events=EvStore(target);var handler=events[type];var allHandler=events.event;if(!handler&&!allHandler){return getListener(target.parentNode,type)}var handlers=[].concat(handler||[],allHandler||[]);return new Listener(target,handlers)}function callListeners(handlers,ev){handlers.forEach(function(handler){if(typeof handler==="function"){handler(ev)}else if(typeof handler.handleEvent==="function"){handler.handleEvent(ev)}else if(handler.type==="dom-delegator-handle"){HANDLER_STORE(handler).func(ev)}else{throw new Error("dom-delegator: unknown handler "+"found: "+JSON.stringify(handlers))}})}function Listener(target,handlers){this.currentTarget=target;this.handlers=handlers}function Handle(){this.type="dom-delegator-handle"}},{"./add-event.js":3,"./proxy-event.js":15,"./remove-event.js":16,"ev-store":7,"global/document":10,"weakmap-shim/create-store":13}],5:[function(require,module,exports){var Individual=require("individual");var cuid=require("cuid");var globalDocument=require("global/document");var DOMDelegator=require("./dom-delegator.js");var versionKey="13";var cacheKey="__DOM_DELEGATOR_CACHE@"+versionKey;var cacheTokenKey="__DOM_DELEGATOR_CACHE_TOKEN@"+versionKey;var delegatorCache=Individual(cacheKey,{delegators:{}});var commonEvents=["blur","change","click","contextmenu","dblclick","error","focus","focusin","focusout","input","keydown","keypress","keyup","load","mousedown","mouseup","resize","select","submit","touchcancel","touchend","touchstart","unload"];module.exports=Delegator;function Delegator(opts){opts=opts||{};var document=opts.document||globalDocument;var cacheKey=document[cacheTokenKey];if(!cacheKey){cacheKey=document[cacheTokenKey]=cuid()}var delegator=delegatorCache.delegators[cacheKey];if(!delegator){delegator=delegatorCache.delegators[cacheKey]=new DOMDelegator(document)}if(opts.defaultEvents!==false){for(var i=0;i<commonEvents.length;i++){delegator.listenTo(commonEvents[i])}}return delegator}Delegator.allocateHandle=DOMDelegator.allocateHandle;Delegator.transformHandle=DOMDelegator.transformHandle},{"./dom-delegator.js":4,cuid:6,"global/document":10,individual:11}],6:[function(require,module,exports){(function(app){"use strict";var namespace="cuid",c=0,blockSize=4,base=36,discreteValues=Math.pow(base,blockSize),pad=function pad(num,size){var s="000000000"+num;return s.substr(s.length-size)},randomBlock=function randomBlock(){return pad((Math.random()*discreteValues<<0).toString(base),blockSize)},safeCounter=function(){c=c<discreteValues?c:0;c++;return c-1},api=function cuid(){var letter="c",timestamp=(new Date).getTime().toString(base),counter,fingerprint=api.fingerprint(),random=randomBlock()+randomBlock();counter=pad(safeCounter().toString(base),blockSize);return letter+timestamp+counter+fingerprint+random};api.slug=function slug(){var date=(new Date).getTime().toString(36),counter,print=api.fingerprint().slice(0,1)+api.fingerprint().slice(-1),random=randomBlock().slice(-2);counter=safeCounter().toString(36).slice(-4);return date.slice(-2)+counter+print+random};api.globalCount=function globalCount(){var cache=function calc(){var i,count=0;for(i in window){count++}return count}();api.globalCount=function(){return cache};return cache};api.fingerprint=function browserPrint(){return pad((navigator.mimeTypes.length+navigator.userAgent.length).toString(36)+api.globalCount().toString(36),4)};if(app.register){app.register(namespace,api)}else if(typeof module!=="undefined"){module.exports=api}else{app[namespace]=api}})(this.applitude||this)},{}],7:[function(require,module,exports){"use strict";var OneVersionConstraint=require("individual/one-version");var MY_VERSION="7";OneVersionConstraint("ev-store",MY_VERSION);var hashKey="__EV_STORE_KEY@"+MY_VERSION;module.exports=EvStore;function EvStore(elem){var hash=elem[hashKey];if(!hash){hash=elem[hashKey]={}}return hash}},{"individual/one-version":9}],8:[function(require,module,exports){(function(global){"use strict";var root=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};module.exports=Individual;function Individual(key,value){if(key in root){return root[key]}root[key]=value;return value}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],9:[function(require,module,exports){"use strict";var Individual=require("./index.js");module.exports=OneVersion;function OneVersion(moduleName,version,defaultValue){var key="__INDIVIDUAL_ONE_VERSION_"+moduleName;var enforceKey=key+"_ENFORCE_SINGLETON";var versionValue=Individual(enforceKey,version);if(versionValue!==version){throw new Error("Can only have one copy of "+moduleName+".\n"+"You already have version "+versionValue+" installed.\n"+"This means you cannot install version "+version)}return Individual(key,defaultValue)}},{"./index.js":8}],10:[function(require,module,exports){(function(global){var topLevel=typeof global!=="undefined"?global:typeof window!=="undefined"?window:{};var minDoc=require("min-document");if(typeof document!=="undefined"){module.exports=document}else{var doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"];if(!doccy){doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"]=minDoc}module.exports=doccy}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"min-document":1}],11:[function(require,module,exports){(function(global){var root=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};module.exports=Individual;function Individual(key,value){if(root[key]){return root[key]}Object.defineProperty(root,key,{value:value,configurable:true});return value}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],12:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],13:[function(require,module,exports){var hiddenStore=require("./hidden-store.js");module.exports=createStore;function createStore(){var key={};return function(obj){if((typeof obj!=="object"||obj===null)&&typeof obj!=="function"){throw new Error("Weakmap-shim: Key must be object")}var store=obj.valueOf(key);return store&&store.identity===key?store:hiddenStore(obj,key)}}},{"./hidden-store.js":14}],14:[function(require,module,exports){module.exports=hiddenStore;function hiddenStore(obj,key){var store={identity:key};var valueOf=obj.valueOf;Object.defineProperty(obj,"valueOf",{ | |
value:function(value){return value!==key?valueOf.apply(this,arguments):store},writable:true});return store}},{}],15:[function(require,module,exports){var inherits=require("inherits");var ALL_PROPS=["altKey","bubbles","cancelable","ctrlKey","eventPhase","metaKey","relatedTarget","shiftKey","target","timeStamp","type","view","which"];var KEY_PROPS=["char","charCode","key","keyCode"];var MOUSE_PROPS=["button","buttons","clientX","clientY","layerX","layerY","offsetX","offsetY","pageX","pageY","screenX","screenY","toElement"];var rkeyEvent=/^key|input/;var rmouseEvent=/^(?:mouse|pointer|contextmenu)|click/;module.exports=ProxyEvent;function ProxyEvent(ev){if(!(this instanceof ProxyEvent)){return new ProxyEvent(ev)}if(rkeyEvent.test(ev.type)){return new KeyEvent(ev)}else if(rmouseEvent.test(ev.type)){return new MouseEvent(ev)}for(var i=0;i<ALL_PROPS.length;i++){var propKey=ALL_PROPS[i];this[propKey]=ev[propKey]}this._rawEvent=ev;this._bubbles=false}ProxyEvent.prototype.preventDefault=function(){this._rawEvent.preventDefault()};ProxyEvent.prototype.startPropagation=function(){this._bubbles=true};function MouseEvent(ev){for(var i=0;i<ALL_PROPS.length;i++){var propKey=ALL_PROPS[i];this[propKey]=ev[propKey]}for(var j=0;j<MOUSE_PROPS.length;j++){var mousePropKey=MOUSE_PROPS[j];this[mousePropKey]=ev[mousePropKey]}this._rawEvent=ev}inherits(MouseEvent,ProxyEvent);function KeyEvent(ev){for(var i=0;i<ALL_PROPS.length;i++){var propKey=ALL_PROPS[i];this[propKey]=ev[propKey]}for(var j=0;j<KEY_PROPS.length;j++){var keyPropKey=KEY_PROPS[j];this[keyPropKey]=ev[keyPropKey]}this._rawEvent=ev}inherits(KeyEvent,ProxyEvent)},{inherits:12}],16:[function(require,module,exports){var EvStore=require("ev-store");module.exports=removeEvent;function removeEvent(target,type,handler){var events=EvStore(target);var event=events[type];if(!event){return}else if(Array.isArray(event)){var index=event.indexOf(handler);if(index!==-1){event.splice(index,1)}}else if(event===handler){events[type]=null}}},{"ev-store":7}],17:[function(require,module,exports){module.exports=Event;function Event(){var listeners=[];return{broadcast:broadcast,listen:event};function broadcast(value){for(var i=0;i<listeners.length;i++){listeners[i](value)}}function event(listener){listeners.push(listener);return removeListener;function removeListener(){var index=listeners.indexOf(listener);if(index!==-1){listeners.splice(index,1)}}}}},{}],18:[function(require,module,exports){var event=require("./single.js");module.exports=multiple;function multiple(names){return names.reduce(function(acc,name){acc[name]=event();return acc},{})}},{"./single.js":19}],19:[function(require,module,exports){var Event=require("./event.js");module.exports=Single;function Single(){var tuple=Event();return function event(value){if(typeof value==="function"){return tuple.listen(value)}else{return tuple.broadcast(value)}}}},{"./event.js":17}],20:[function(require,module,exports){var raf=require("raf");var TypedError=require("error/typed");var InvalidUpdateInRender=TypedError({type:"main-loop.invalid.update.in-render",message:"main-loop: Unexpected update occurred in loop.\n"+"We are currently rendering a view, "+"you can't change state right now.\n"+"The diff is: {stringDiff}.\n"+"SUGGESTED FIX: find the state mutation in your view "+"or rendering function and remove it.\n"+"The view should not have any side effects.\n",diff:null,stringDiff:null});module.exports=main;function main(initialState,view,opts){opts=opts||{};var currentState=initialState;var create=opts.create;var diff=opts.diff;var patch=opts.patch;var redrawScheduled=false;var tree=opts.initialTree||view(currentState);var target=opts.target||create(tree,opts);var inRenderingTransaction=false;currentState=null;return{target:target,update:update};function update(state){if(inRenderingTransaction){throw InvalidUpdateInRender({diff:state._diff,stringDiff:JSON.stringify(state._diff)})}if(currentState===null&&!redrawScheduled){redrawScheduled=true;raf(redraw)}currentState=state}function redraw(){redrawScheduled=false;if(currentState===null){return}inRenderingTransaction=true;var newTree=view(currentState);if(opts.createOnly){inRenderingTransaction=false;create(newTree,opts)}else{var patches=diff(tree,newTree,opts);inRenderingTransaction=false;target=patch(target,patches,opts)}tree=newTree;currentState=null}}},{"error/typed":23,raf:24}],21:[function(require,module,exports){module.exports=function(obj){if(typeof obj==="string")return camelCase(obj);return walk(obj)};function walk(obj){if(!obj||typeof obj!=="object")return obj;if(isDate(obj)||isRegex(obj))return obj;if(isArray(obj))return map(obj,walk);return reduce(objectKeys(obj),function(acc,key){var camel=camelCase(key);acc[camel]=walk(obj[key]);return acc},{})}function camelCase(str){return str.replace(/[_.-](\w|$)/g,function(_,x){return x.toUpperCase()})}var isArray=Array.isArray||function(obj){return Object.prototype.toString.call(obj)==="[object Array]"};var isDate=function(obj){return Object.prototype.toString.call(obj)==="[object Date]"};var isRegex=function(obj){return Object.prototype.toString.call(obj)==="[object RegExp]"};var has=Object.prototype.hasOwnProperty;var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj){if(has.call(obj,key))keys.push(key)}return keys};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i))}return res}function reduce(xs,f,acc){if(xs.reduce)return xs.reduce(f,acc);for(var i=0;i<xs.length;i++){acc=f(acc,xs[i],i)}return acc}},{}],22:[function(require,module,exports){var nargs=/\{([0-9a-zA-Z]+)\}/g;var slice=Array.prototype.slice;module.exports=template;function template(string){var args;if(arguments.length===2&&typeof arguments[1]==="object"){args=arguments[1]}else{args=slice.call(arguments,1)}if(!args||!args.hasOwnProperty){args={}}return string.replace(nargs,function replaceArg(match,i,index){var result;if(string[index-1]==="{"&&string[index+match.length]==="}"){return i}else{result=args.hasOwnProperty(i)?args[i]:null;if(result===null||result===undefined){return""}return result}})}},{}],23:[function(require,module,exports){var camelize=require("camelize");var template=require("string-template");var extend=require("xtend/mutable");module.exports=TypedError;function TypedError(args){if(!args){throw new Error("args is required")}if(!args.type){throw new Error("args.type is required")}if(!args.message){throw new Error("args.message is required")}var message=args.message;if(args.type&&!args.name){var errorName=camelize(args.type)+"Error";args.name=errorName[0].toUpperCase()+errorName.substr(1)}extend(createError,args);createError._name=args.name;return createError;function createError(opts){var result=new Error;Object.defineProperty(result,"type",{value:result.type,enumerable:true,writable:true,configurable:true});var options=extend({},args,opts);extend(result,options);result.message=template(message,options);return result}}},{camelize:21,"string-template":22,"xtend/mutable":91}],24:[function(require,module,exports){var now=require("performance-now"),global=typeof window==="undefined"?{}:window,vendors=["moz","webkit"],suffix="AnimationFrame",raf=global["request"+suffix],caf=global["cancel"+suffix]||global["cancelRequest"+suffix],isNative=true;for(var i=0;i<vendors.length&&!raf;i++){raf=global[vendors[i]+"Request"+suffix];caf=global[vendors[i]+"Cancel"+suffix]||global[vendors[i]+"CancelRequest"+suffix]}if(!raf||!caf){isNative=false;var last=0,id=0,queue=[],frameDuration=1e3/60;raf=function(callback){if(queue.length===0){var _now=now(),next=Math.max(0,frameDuration-(_now-last));last=next+_now;setTimeout(function(){var cp=queue.slice(0);queue.length=0;for(var i=0;i<cp.length;i++){if(!cp[i].cancelled){try{cp[i].callback(last)}catch(e){setTimeout(function(){throw e},0)}}}},Math.round(next))}queue.push({handle:++id,callback:callback,cancelled:false});return id};caf=function(handle){for(var i=0;i<queue.length;i++){if(queue[i].handle===handle){queue[i].cancelled=true}}}}module.exports=function(fn){if(!isNative){return raf.call(global,fn)}return raf.call(global,function(){try{fn.apply(this,arguments)}catch(e){setTimeout(function(){throw e},0)}})};module.exports.cancel=function(){caf.apply(global,arguments)}},{"performance-now":25}],25:[function(require,module,exports){(function(process){(function(){var getNanoSeconds,hrtime,loadTime;if(typeof performance!=="undefined"&&performance!==null&&performance.now){module.exports=function(){return performance.now()}}else if(typeof process!=="undefined"&&process!==null&&process.hrtime){module.exports=function(){return(getNanoSeconds()-loadTime)/1e6};hrtime=process.hrtime;getNanoSeconds=function(){var hr;hr=hrtime();return hr[0]*1e9+hr[1]};loadTime=getNanoSeconds()}else if(Date.now){module.exports=function(){return Date.now()-loadTime};loadTime=Date.now()}else{module.exports=function(){return(new Date).getTime()-loadTime};loadTime=(new Date).getTime()}}).call(this)}).call(this,require("_process"))},{_process:2}],26:[function(require,module,exports){var setNonEnumerable=require("./lib/set-non-enumerable.js");module.exports=addListener;function addListener(observArray,observ){var list=observArray._list;return observ(function(value){var valueList=observArray().slice();var index=list.indexOf(observ);if(index===-1){var message="observ-array: Unremoved observ listener";var err=new Error(message);err.list=list;err.index=index;err.observ=observ;throw err}valueList.splice(index,1,value);setNonEnumerable(valueList,"_diff",[[index,1,value]]);observArray._observSet(valueList)})}},{"./lib/set-non-enumerable.js":32}],27:[function(require,module,exports){var addListener=require("./add-listener.js");module.exports=applyPatch;function applyPatch(valueList,args){var obs=this;var valueArgs=args.map(unpack);valueList.splice.apply(valueList,valueArgs);obs._list.splice.apply(obs._list,args);var extraRemoveListeners=args.slice(2).map(function(observ){return typeof observ==="function"?addListener(obs,observ):null});extraRemoveListeners.unshift(args[0],args[1]);var removedListeners=obs._removeListeners.splice.apply(obs._removeListeners,extraRemoveListeners);removedListeners.forEach(function(removeObservListener){if(removeObservListener){removeObservListener()}});return valueArgs}function unpack(value,index){if(index===0||index===1){return value}return typeof value==="function"?value():value}},{"./add-listener.js":26}],28:[function(require,module,exports){var ObservArray=require("./index.js");var slice=Array.prototype.slice;var ARRAY_METHODS=["concat","slice","every","filter","forEach","indexOf","join","lastIndexOf","map","reduce","reduceRight","some","toString","toLocaleString"];var methods=ARRAY_METHODS.map(function(name){return[name,function(){var res=this._list[name].apply(this._list,arguments);if(res&&Array.isArray(res)){res=ObservArray(res)}return res}]});module.exports=ArrayMethods;function ArrayMethods(obs){obs.push=observArrayPush;obs.pop=observArrayPop;obs.shift=observArrayShift;obs.unshift=observArrayUnshift;obs.reverse=require("./array-reverse.js");obs.sort=require("./array-sort.js");methods.forEach(function(tuple){obs[tuple[0]]=tuple[1]});return obs}function observArrayPush(){var args=slice.call(arguments);args.unshift(this._list.length,0);this.splice.apply(this,args);return this._list.length}function observArrayPop(){return this.splice(this._list.length-1,1)[0]}function observArrayShift(){return this.splice(0,1)[0]}function observArrayUnshift(){var args=slice.call(arguments);args.unshift(0,0);this.splice.apply(this,args);return this._list.length}function notImplemented(){throw new Error("Pull request welcome")}},{"./array-reverse.js":29,"./array-sort.js":30,"./index.js":31}],29:[function(require,module,exports){var applyPatch=require("./apply-patch.js");var setNonEnumerable=require("./lib/set-non-enumerable.js");module.exports=reverse;function reverse(){var obs=this;var changes=fakeDiff(obs._list.slice().reverse());var valueList=obs().slice().reverse();var valueChanges=changes.map(applyPatch.bind(obs,valueList));setNonEnumerable(valueList,"_diff",valueChanges);obs._observSet(valueList);return changes}function fakeDiff(arr){var _diff;var len=arr.length;if(len%2){var midPoint=(len-1)/2;var a=[0,midPoint].concat(arr.slice(0,midPoint));var b=[midPoint+1,midPoint].concat(arr.slice(midPoint+1,len));var _diff=[a,b]}else{_diff=[[0,len].concat(arr)]}return _diff}},{"./apply-patch.js":27,"./lib/set-non-enumerable.js":32}],30:[function(require,module,exports){var applyPatch=require("./apply-patch.js");var setNonEnumerable=require("./lib/set-non-enumerable.js");module.exports=sort;function sort(compare){var obs=this;var list=obs._list.slice();var unpacked=unpack(list);var sorted=unpacked.map(function(it){return it.val}).sort(compare);var packed=repack(sorted,unpacked);var changes=[[0,packed.length].concat(packed)];var valueChanges=changes.map(applyPatch.bind(obs,sorted));setNonEnumerable(sorted,"_diff",valueChanges);obs._observSet(sorted);return changes}function unpack(list){var unpacked=[];for(var i=0;i<list.length;i++){unpacked.push({val:"function"==typeof list[i]?list[i]():list[i],obj:list[i]})}return unpacked}function repack(sorted,unpacked){var packed=[];while(sorted.length){var s=sorted.shift();var indx=indexOf(s,unpacked);if(~indx)packed.push(unpacked.splice(indx,1)[0].obj)}return packed}function indexOf(n,h){for(var i=0;i<h.length;i++){if(n===h[i].val)return i}return-1}},{"./apply-patch.js":27,"./lib/set-non-enumerable.js":32}],31:[function(require,module,exports){var Observ=require("observ");module.exports=ObservArray;var splice=require("./splice.js");var put=require("./put.js");var set=require("./set.js");var transaction=require("./transaction.js");var ArrayMethods=require("./array-methods.js");var addListener=require("./add-listener.js");function ObservArray(initialList){var list=initialList;var initialState=[];list.forEach(function(observ,index){initialState[index]=typeof observ==="function"?observ():observ});var obs=Observ(initialState);obs.splice=splice;obs._observSet=obs.set;obs.set=set;obs.get=get;obs.getLength=getLength;obs.put=put;obs.transaction=transaction;obs._list=list;var removeListeners=list.map(function(observ){return typeof observ==="function"?addListener(obs,observ):null});obs._removeListeners=removeListeners;obs._type="observ-array";obs._version="3";return ArrayMethods(obs,list)}function get(index){return this._list[index]}function getLength(){return this._list.length}},{"./add-listener.js":26,"./array-methods.js":28,"./put.js":34,"./set.js":35,"./splice.js":36,"./transaction.js":37,observ:43}],32:[function(require,module,exports){module.exports=setNonEnumerable;function setNonEnumerable(object,key,value){Object.defineProperty(object,key,{value:value,writable:true,configurable:true,enumerable:false})}},{}],33:[function(require,module,exports){function head(a){return a[0]}function last(a){return a[a.length-1]}function tail(a){return a.slice(1)}function retreat(e){return e.pop()}function hasLength(e){return e.length}function any(ary,test){for(var i=0;i<ary.length;i++)if(test(ary[i]))return true;return false}function score(a){return a.reduce(function(s,a){return s+a.length+a[1]+1},0)}function best(a,b){return score(a)<=score(b)?a:b}var _rules;function _equal(a,b){if(a&&!b)return false;if(Array.isArray(a))if(a.length!=b.length)return false;if(a&&"object"==typeof a){for(var i in a)if(!_equal(a[i],b[i]))return false;for(var i in b)if(!_equal(a[i],b[i]))return false;return true}return a==b}function getArgs(args){return args.length==1?args[0]:[].slice.call(args)}function oddElement(ary,cmp){var c;function guess(a){var odd=-1;c=0;for(var i=a;i<ary.length;i++){if(!cmp(ary[a],ary[i])){odd=i,c++}}return c>1?-1:odd}var g=guess(0);if(-1!=g)return g;guess(1);return c==0?0:-1}var exports=module.exports=function(deps,exports){var equal=deps&&deps.equal||_equal;exports=exports||{};exports.lcs=function lcs(){var cache={};var args=getArgs(arguments);var a=args[0],b=args[1];function key(a,b){return a.length+":"+b.length}if(args.length>2){args.push(lcs(args.shift(),args.shift()));return lcs(args)}var start=0,end=0;for(var i=0;i<a.length&&i<b.length&&equal(a[i],b[i]);i++)start=i+1;if(a.length===start)return a.slice();for(var i=0;i<a.length-start&&i<b.length-start&&equal(a[a.length-1-i],b[b.length-1-i]);i++)end=i;function recurse(a,b){if(!a.length||!b.length)return[];if(cache[key(a,b)])return cache[key(a,b)];if(equal(a[0],b[0]))return[head(a)].concat(recurse(tail(a),tail(b)));else{var _a=recurse(tail(a),b);var _b=recurse(a,tail(b));return cache[key(a,b)]=_a.length>_b.length?_a:_b}}var middleA=a.slice(start,a.length-end);var middleB=b.slice(start,b.length-end);return a.slice(0,start).concat(recurse(middleA,middleB)).concat(a.slice(a.length-end))};exports.chunk=function(q,build){var q=q.map(function(e){return e.slice()});var lcs=exports.lcs.apply(null,q);var all=[lcs].concat(q);function matchLcs(e){if(e.length&&!lcs.length||!e.length&&lcs.length)return false;return equal(last(e),last(lcs))||e.length+lcs.length===0}while(any(q,hasLength)){while(q.every(matchLcs)&&q.every(hasLength))all.forEach(retreat);var c=false;var unstable=q.map(function(e){var change=[];while(!matchLcs(e)){change.unshift(retreat(e));c=true}return change});if(c)build(q[0].length,unstable)}};exports.optimisticDiff=function(a,b){var M=Math.max(a.length,b.length);var m=Math.min(a.length,b.length);var patch=[];for(var i=0;i<M;i++)if(a[i]!==b[i]){var cur=[i,0],deletes=0;while(a[i]!==b[i]&&i<m){cur[1]=++deletes;cur.push(b[i++])}if(i>=m){if(a.length>b.length)cur[1]+=a.length-b.length;else if(a.length<b.length)cur=cur.concat(b.slice(a.length))}patch.push(cur)}return patch};exports.diff=function(a,b){var optimistic=exports.optimisticDiff(a,b);var changes=[];exports.chunk([a,b],function(index,unstable){var del=unstable.shift().length;var insert=unstable.shift();changes.push([index,del].concat(insert))});return best(optimistic,changes)};exports.patch=function(a,changes,mutate){if(mutate!==true)a=a.slice(a);changes.forEach(function(change){[].splice.apply(a,change)});return a};exports.merge=function(){var args=getArgs(arguments);var patch=exports.diff3(args);return exports.patch(args[0],patch)};exports.diff3=function(){var args=getArgs(arguments);var r=[];exports.chunk(args,function(index,unstable){var mine=unstable[0];var insert=resolve(unstable);if(equal(mine,insert))return;r.push([index,mine.length].concat(insert))});return r};exports.oddOneOut=function oddOneOut(changes){changes=changes.slice();changes.unshift(changes.splice(1,1)[0]);var i=oddElement(changes,equal);if(i==0)return changes[1];if(~i)return changes[i]};exports.insertMergeOverDelete=function insertMergeOverDelete(changes){changes=changes.slice();changes.splice(1,1);for(var i=0,nonempty;i<changes.length;i++)if(changes[i].length)if(!nonempty)nonempty=changes[i];else return;return nonempty};var rules=deps&&deps.rules||[exports.oddOneOut,exports.insertMergeOverDelete];function resolve(changes){var l=rules.length;for(var i in rules){var c=rules[i]&&rules[i](changes);if(c)return c}changes.splice(1,1);return{"?":changes}}return exports};exports(null,exports)},{}],34:[function(require,module,exports){var addListener=require("./add-listener.js");var setNonEnumerable=require("./lib/set-non-enumerable.js");module.exports=put;function put(index,value){var obs=this;var valueList=obs().slice();var originalLength=valueList.length;valueList[index]=typeof value==="function"?value():value;obs._list[index]=value;var removeListener=obs._removeListeners[index];if(removeListener){removeListener()}obs._removeListeners[index]=typeof value==="function"?addListener(obs,value):null;var valueArgs=index<originalLength?[index,1,valueList[index]]:[index,0,valueList[index]];setNonEnumerable(valueList,"_diff",[valueArgs]);obs._observSet(valueList);return value}},{"./add-listener.js":26,"./lib/set-non-enumerable.js":32}],35:[function(require,module,exports){var applyPatch=require("./apply-patch.js");var setNonEnumerable=require("./lib/set-non-enumerable.js");var adiff=require("adiff");module.exports=set;function set(rawList){if(!Array.isArray(rawList))rawList=[];var obs=this;var changes=adiff.diff(obs._list,rawList);var valueList=obs().slice();var valueChanges=changes.map(applyPatch.bind(obs,valueList));setNonEnumerable(valueList,"_diff",valueChanges);obs._observSet(valueList);return changes}},{"./apply-patch.js":27,"./lib/set-non-enumerable.js":32,adiff:33}],36:[function(require,module,exports){var slice=Array.prototype.slice;var addListener=require("./add-listener.js");var setNonEnumerable=require("./lib/set-non-enumerable.js");module.exports=splice;function splice(index,amount){var obs=this;var args=slice.call(arguments,0);var valueList=obs().slice();var valueArgs=args.map(function(value,index){if(index===0||index===1){return value}return typeof value==="function"?value():value});valueList.splice.apply(valueList,valueArgs);var removed=obs._list.splice.apply(obs._list,args);var extraRemoveListeners=args.slice(2).map(function(observ){return typeof observ==="function"?addListener(obs,observ):null});extraRemoveListeners.unshift(args[0],args[1]);var removedListeners=obs._removeListeners.splice.apply(obs._removeListeners,extraRemoveListeners);removedListeners.forEach(function(removeObservListener){if(removeObservListener){removeObservListener()}});setNonEnumerable(valueList,"_diff",[valueArgs]);obs._observSet(valueList);return removed}},{"./add-listener.js":26,"./lib/set-non-enumerable.js":32}],37:[function(require,module,exports){module.exports=transaction;function transaction(func){var obs=this;var rawList=obs._list.slice();if(func(rawList)!==false){return obs.set(rawList)}}},{}],38:[function(require,module,exports){var Observ=require("observ");var extend=require("xtend");var blackList=["name","_diff","_type","_version"];var blackListReasons={name:"Clashes with `Function.prototype.name`.\n",_diff:"_diff is reserved key of observ-struct.\n",_type:"_type is reserved key of observ-struct.\n",_version:"_version is reserved key of observ-struct.\n"};var NO_TRANSACTION={};function setNonEnumerable(object,key,value){Object.defineProperty(object,key,{value:value,writable:true,configurable:true,enumerable:false})}module.exports=ObservStruct;function ObservStruct(struct){var keys=Object.keys(struct);var initialState={};var currentTransaction=NO_TRANSACTION;var nestedTransaction=NO_TRANSACTION;keys.forEach(function(key){if(blackList.indexOf(key)!==-1){throw new Error("cannot create an observ-struct "+"with a key named '"+key+"'.\n"+blackListReasons[key])}var observ=struct[key];initialState[key]=typeof observ==="function"?observ():observ});var obs=Observ(initialState);keys.forEach(function(key){var observ=struct[key];obs[key]=observ;if(typeof observ==="function"){observ(function(value){if(nestedTransaction===value){return}var state=extend(obs());state[key]=value;var diff={};diff[key]=value&&value._diff?value._diff:value;setNonEnumerable(state,"_diff",diff);currentTransaction=state;obs.set(state);currentTransaction=NO_TRANSACTION})}});var _set=obs.set;obs.set=function trackDiff(value){if(currentTransaction===value){return _set(value)}var newState=extend(value);setNonEnumerable(newState,"_diff",value);_set(newState)};obs(function(newState){if(currentTransaction===newState){return}keys.forEach(function(key){var observ=struct[key];var newObservValue=newState[key];if(typeof observ==="function"&&observ()!==newObservValue){nestedTransaction=newObservValue;observ.set(newState[key]);nestedTransaction=NO_TRANSACTION}})});obs._type="observ-struct";obs._version="5";return obs}},{observ:43,xtend:39}],39:[function(require,module,exports){module.exports=extend;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(source.hasOwnProperty(key)){target[key]=source[key]}}}return target}},{}],40:[function(require,module,exports){var Observ=require("observ");var extend=require("xtend");var NO_TRANSACTION={};module.exports=ObservVarhash;function ObservVarhash(hash,createValue){createValue=createValue||function(obj){return obj};var initialState={};var currentTransaction=NO_TRANSACTION;var obs=Observ(initialState);setNonEnumerable(obs,"_removeListeners",{});setNonEnumerable(obs,"set",obs.set);setNonEnumerable(obs,"get",get.bind(obs));setNonEnumerable(obs,"put",put.bind(obs,createValue,currentTransaction));setNonEnumerable(obs,"delete",del.bind(obs));for(var key in hash){obs[key]=typeof hash[key]==="function"?hash[key]:createValue(hash[key],key);if(isFn(obs[key])){obs._removeListeners[key]=obs[key](watch(obs,key,currentTransaction))}}var newState={};for(key in hash){var observ=obs[key];checkKey(key);newState[key]=isFn(observ)?observ():observ}obs.set(newState);obs(function(newState){if(currentTransaction===newState){return}for(var key in hash){var observ=hash[key];if(isFn(observ)&&observ()!==newState[key]){observ.set(newState[key])}}});return obs}function get(key){return this[key]}function put(createValue,currentTransaction,key,val){checkKey(key);if(val===undefined){throw new Error("cannot varhash.put(key, undefined).")}var observ=typeof val==="function"?val:createValue(val,key);var state=extend(this());state[key]=isFn(observ)?observ():observ;if(isFn(this._removeListeners[key])){this._removeListeners[key]()}this._removeListeners[key]=isFn(observ)?observ(watch(this,key,currentTransaction)):null;setNonEnumerable(state,"_diff",diff(key,state[key]));this[key]=observ;this.set(state);return this}function del(key){var state=extend(this());if(isFn(this._removeListeners[key])){this._removeListeners[key]()}delete this._removeListeners[key];delete state[key];delete this[key];setNonEnumerable(state,"_diff",diff(key,undefined));this.set(state);return this}function watch(obs,key,currentTransaction){return function(value){var state=extend(obs());state[key]=value;setNonEnumerable(state,"_diff",diff(key,value));currentTransaction=state;obs.set(state);currentTransaction=NO_TRANSACTION}}function diff(key,value){var obj={};obj[key]=value&&value._diff?value._diff:value;return obj}function isFn(obj){return typeof obj==="function"}function setNonEnumerable(object,key,value){Object.defineProperty(object,key,{value:value,writable:true,configurable:true,enumerable:false})}var blacklist={name:"Clashes with `Function.prototype.name`.",get:"get is a reserved key of observ-varhash method",put:"put is a reserved key of observ-varhash method","delete":"delete is a reserved key of observ-varhash method",_diff:"_diff is a reserved key of observ-varhash method",_removeListeners:"_removeListeners is a reserved key of observ-varhash"};function checkKey(key){if(!blacklist[key])return;throw new Error("cannot create an observ-varhash with key `"+key+"`. "+blacklist[key])}},{observ:43,xtend:41}],41:[function(require,module,exports){arguments[4][39][0].apply(exports,arguments)},{dup:39}],42:[function(require,module,exports){var Observable=require("./index.js");module.exports=computed;function computed(observables,lambda){var values=observables.map(function(o){return o()});var result=Observable(lambda.apply(null,values));observables.forEach(function(o,index){o(function(newValue){values[index]=newValue;result.set(lambda.apply(null,values))})});return result}},{"./index.js":43}],43:[function(require,module,exports){module.exports=Observable;function Observable(value){var listeners=[];value=value===undefined?null:value;observable.set=function(v){value=v;listeners.forEach(function(f){f(v)})};return observable;function observable(listener){if(!listener){return value}listeners.push(listener);return function remove(){listeners.splice(listeners.indexOf(listener),1)}}}},{}],44:[function(require,module,exports){module.exports=watch;function watch(observable,listener){var remove=observable(listener);listener(observable());return remove}},{}],45:[function(require,module,exports){var Delegator=require("dom-delegator");module.exports=BaseEvent;function BaseEvent(lambda){return EventHandler;function EventHandler(fn,data,opts){var handler={fn:fn,data:data!==undefined?data:{},opts:opts||{},handleEvent:handleEvent};if(fn&&fn.type==="dom-delegator-handle"){return Delegator.transformHandle(fn,handleLambda.bind(handler))}return handler}function handleLambda(ev,broadcast){if(this.opts.startPropagation&&ev.startPropagation){ev.startPropagation()}return lambda.call(this,ev,broadcast)}function handleEvent(ev){var self=this;if(self.opts.startPropagation&&ev.startPropagation){ev.startPropagation()}lambda.call(self,ev,broadcast);function broadcast(value){if(typeof self.fn==="function"){self.fn(value)}else{self.fn.write(value)}}}}},{"dom-delegator":5}],46:[function(require,module,exports){var extend=require("xtend");var getFormData=require("form-data-set/element");var BaseEvent=require("./base-event.js");var VALID_CHANGE=["checkbox","file","select-multiple","select-one"];var VALID_INPUT=["color","date","datetime","datetime-local","email","month","number","password","range","search","tel","text","time","url","week"];module.exports=BaseEvent(changeLambda);function changeLambda(ev,broadcast){var target=ev.target;var isValid=ev.type==="input"&&VALID_INPUT.indexOf(target.type)!==-1||ev.type==="change"&&VALID_CHANGE.indexOf(target.type)!==-1;if(!isValid){if(ev.startPropagation){ev.startPropagation()}return}var value=getFormData(ev.currentTarget);var data=extend(value,this.data);broadcast(data)}},{"./base-event.js":45,"form-data-set/element":51,xtend:54}],47:[function(require,module,exports){var BaseEvent=require("./base-event.js");module.exports=BaseEvent(clickLambda);function clickLambda(ev,broadcast){var opts=this.opts;if(!opts.ctrl&&ev.ctrlKey){return}if(!opts.meta&&ev.metaKey){return}if(!opts.rightClick&&ev.which===2){return}if(this.opts.preventDefault&&ev.preventDefault){ev.preventDefault()}broadcast(this.data)}},{"./base-event.js":45}],48:[function(require,module,exports){var BaseEvent=require("./base-event.js");module.exports=BaseEvent(eventLambda);function eventLambda(ev,broadcast){broadcast(this.data)}},{"./base-event.js":45}],49:[function(require,module,exports){var BaseEvent=require("./base-event.js");module.exports=BaseEvent(keyLambda);function keyLambda(ev,broadcast){var key=this.opts.key;if(ev.keyCode===key){broadcast(this.data)}}},{"./base-event.js":45}],50:[function(require,module,exports){var slice=Array.prototype.slice;module.exports=iterativelyWalk;function iterativelyWalk(nodes,cb){if(!("length"in nodes)){nodes=[nodes]}nodes=slice.call(nodes);while(nodes.length){var node=nodes.shift(),ret=cb(node);if(ret){return ret}if(node.childNodes&&node.childNodes.length){nodes=slice.call(node.childNodes).concat(nodes)}}}},{}],51:[function(require,module,exports){var walk=require("dom-walk");var FormData=require("./index.js");module.exports=getFormData;function buildElems(rootElem){var hash={};if(rootElem.name){hash[rootElem.name]=rootElem}walk(rootElem,function(child){if(child.name){hash[child.name]=child}});return hash}function getFormData(rootElem){var elements=buildElems(rootElem);return FormData(elements)}},{"./index.js":52,"dom-walk":50}],52:[function(require,module,exports){module.exports=FormData;function FormData(elements){return Object.keys(elements).reduce(function(acc,key){var elem=elements[key];acc[key]=valueOfElement(elem);return acc},{})}function valueOfElement(elem){if(typeof elem==="function"){return elem()}else if(containsRadio(elem)){var elems=toList(elem);var checked=elems.filter(function(elem){return elem.checked})[0]||null;return checked?checked.value:null}else if(Array.isArray(elem)){return elem.map(valueOfElement).filter(filterNull)}else if(elem.tagName===undefined&&elem.nodeType===undefined){return FormData(elem)}else if(elem.tagName==="INPUT"&&isChecked(elem)){if(elem.hasAttribute("value")){return elem.checked?elem.value:null}else{return elem.checked}}else if(elem.tagName==="INPUT"){return elem.value}else if(elem.tagName==="TEXTAREA"){return elem.value}else if(elem.tagName==="SELECT"){return elem.value; | |
}}function isChecked(elem){return elem.type==="checkbox"||elem.type==="radio"}function containsRadio(value){if(value.tagName||value.nodeType){return false}var elems=toList(value);return elems.some(function(elem){return elem.tagName==="INPUT"&&elem.type==="radio"})}function toList(value){if(Array.isArray(value)){return value}return Object.keys(value).map(prop,value)}function prop(x){return this[x]}function filterNull(val){return val!==null}},{}],53:[function(require,module,exports){module.exports=hasKeys;function hasKeys(source){return source!==null&&(typeof source==="object"||typeof source==="function")}},{}],54:[function(require,module,exports){var hasKeys=require("./has-keys");module.exports=extend;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];if(!hasKeys(source)){continue}for(var key in source){if(source.hasOwnProperty(key)){target[key]=source[key]}}}return target}},{"./has-keys":53}],55:[function(require,module,exports){var extend=require("xtend");var getFormData=require("form-data-set/element");var BaseEvent=require("./base-event.js");var ENTER=13;module.exports=BaseEvent(submitLambda);function submitLambda(ev,broadcast){var target=ev.target;var isValid=ev.type==="submit"&&target.tagName==="FORM"||ev.type==="click"&&target.tagName==="BUTTON"||ev.type==="click"&&target.type==="submit"||target.type==="text"&&(ev.keyCode===ENTER&&ev.type==="keydown");if(!isValid){if(ev.startPropagation){ev.startPropagation()}return}var value=getFormData(ev.currentTarget);var data=extend(value,this.data);if(ev.preventDefault){ev.preventDefault()}broadcast(data)}},{"./base-event.js":45,"form-data-set/element":51,xtend:54}],56:[function(require,module,exports){var extend=require("xtend");var getFormData=require("form-data-set/element");var BaseEvent=require("./base-event.js");module.exports=BaseEvent(valueLambda);function valueLambda(ev,broadcast){var value=getFormData(ev.currentTarget);var data=extend(value,this.data);broadcast(data)}},{"./base-event.js":45,"form-data-set/element":51,xtend:54}],57:[function(require,module,exports){function Thunk(fn,args,key,eqArgs){this.fn=fn;this.args=args;this.key=key;this.eqArgs=eqArgs}Thunk.prototype.type="Thunk";Thunk.prototype.render=render;module.exports=Thunk;function shouldUpdate(current,previous){if(!current||!previous||current.fn!==previous.fn){return true}var cargs=current.args;var pargs=previous.args;return!current.eqArgs(cargs,pargs)}function render(previous){if(shouldUpdate(this,previous)){return this.fn.apply(null,this.args)}else{return previous.vnode}}},{}],58:[function(require,module,exports){var Partial=require("./partial");module.exports=Partial()},{"./partial":59}],59:[function(require,module,exports){var shallowEq=require("./shallow-eq");var Thunk=require("./immutable-thunk");module.exports=createPartial;function createPartial(eq){return function partial(fn){var args=copyOver(arguments,1);var firstArg=args[0];var key;var eqArgs=eq||shallowEq;if(typeof firstArg==="object"&&firstArg!==null){if("key"in firstArg){key=firstArg.key}else if("id"in firstArg){key=firstArg.id}}return new Thunk(fn,args,key,eqArgs)}}function copyOver(list,offset){var newList=[];for(var i=list.length-1;i>=offset;i--){newList[i-offset]=list[i]}return newList}},{"./immutable-thunk":57,"./shallow-eq":60}],60:[function(require,module,exports){module.exports=shallowEq;function shallowEq(currentArgs,previousArgs){if(currentArgs.length===0&&previousArgs.length===0){return true}if(currentArgs.length!==previousArgs.length){return false}var len=currentArgs.length;for(var i=0;i<len;i++){if(currentArgs[i]!==previousArgs[i]){return false}}return true}},{}],61:[function(require,module,exports){module.exports=function split(undef){var nativeSplit=String.prototype.split,compliantExecNpcg=/()??/.exec("")[1]===undef,self;self=function(str,separator,limit){if(Object.prototype.toString.call(separator)!=="[object RegExp]"){return nativeSplit.call(str,separator,limit)}var output=[],flags=(separator.ignoreCase?"i":"")+(separator.multiline?"m":"")+(separator.extended?"x":"")+(separator.sticky?"y":""),lastLastIndex=0,separator=new RegExp(separator.source,flags+"g"),separator2,match,lastIndex,lastLength;str+="";if(!compliantExecNpcg){separator2=new RegExp("^"+separator.source+"$(?!\\s)",flags)}limit=limit===undef?-1>>>0:limit>>>0;while(match=separator.exec(str)){lastIndex=match.index+match[0].length;if(lastIndex>lastLastIndex){output.push(str.slice(lastLastIndex,match.index));if(!compliantExecNpcg&&match.length>1){match[0].replace(separator2,function(){for(var i=1;i<arguments.length-2;i++){if(arguments[i]===undef){match[i]=undef}}})}if(match.length>1&&match.index<str.length){Array.prototype.push.apply(output,match.slice(1))}lastLength=match[0].length;lastLastIndex=lastIndex;if(output.length>=limit){break}}if(separator.lastIndex===match.index){separator.lastIndex++}}if(lastLastIndex===str.length){if(lastLength||!separator.test("")){output.push("")}}else{output.push(str.slice(lastLastIndex))}return output.length>limit?output.slice(0,limit):output};return self}()},{}],62:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7,"individual/one-version":64}],63:[function(require,module,exports){(function(global){"use strict";var root=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};module.exports=Individual;function Individual(key,value){if(key in root){return root[key]}root[key]=value;return value}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],64:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./index.js":63,dup:9}],65:[function(require,module,exports){(function(global){var topLevel=typeof global!=="undefined"?global:typeof window!=="undefined"?window:{};var minDoc=require("min-document");if(typeof document!=="undefined"){module.exports=document}else{var doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"];if(!doccy){doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"]=minDoc}module.exports=doccy}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"min-document":1}],66:[function(require,module,exports){"use strict";module.exports=function isObject(x){return typeof x==="object"&&x!==null}},{}],67:[function(require,module,exports){var nativeIsArray=Array.isArray;var toString=Object.prototype.toString;module.exports=nativeIsArray||isArray;function isArray(obj){return toString.call(obj)==="[object Array]"}},{}],68:[function(require,module,exports){var isObject=require("is-object");var isHook=require("../vnode/is-vhook.js");module.exports=applyProperties;function applyProperties(node,props,previous){for(var propName in props){var propValue=props[propName];if(propValue===undefined){removeProperty(node,propName,propValue,previous)}else if(isHook(propValue)){removeProperty(node,propName,propValue,previous);if(propValue.hook){propValue.hook(node,propName,previous?previous[propName]:undefined)}}else{if(isObject(propValue)){patchObject(node,props,previous,propName,propValue)}else{node[propName]=propValue}}}}function removeProperty(node,propName,propValue,previous){if(previous){var previousValue=previous[propName];if(!isHook(previousValue)){if(propName==="attributes"){for(var attrName in previousValue){node.removeAttribute(attrName)}}else if(propName==="style"){for(var i in previousValue){node.style[i]=""}}else if(typeof previousValue==="string"){node[propName]=""}else{node[propName]=null}}else if(previousValue.unhook){previousValue.unhook(node,propName,propValue)}}}function patchObject(node,props,previous,propName,propValue){var previousValue=previous?previous[propName]:undefined;if(propName==="attributes"){for(var attrName in propValue){var attrValue=propValue[attrName];if(attrValue===undefined){node.removeAttribute(attrName)}else{node.setAttribute(attrName,attrValue)}}return}if(previousValue&&isObject(previousValue)&&getPrototype(previousValue)!==getPrototype(propValue)){node[propName]=propValue;return}if(!isObject(node[propName])){node[propName]={}}var replacer=propName==="style"?"":undefined;for(var k in propValue){var value=propValue[k];node[propName][k]=value===undefined?replacer:value}}function getPrototype(value){if(Object.getPrototypeOf){return Object.getPrototypeOf(value)}else if(value.__proto__){return value.__proto__}else if(value.constructor){return value.constructor.prototype}}},{"../vnode/is-vhook.js":80,"is-object":66}],69:[function(require,module,exports){var document=require("global/document");var applyProperties=require("./apply-properties");var isVNode=require("../vnode/is-vnode.js");var isVText=require("../vnode/is-vtext.js");var isWidget=require("../vnode/is-widget.js");var handleThunk=require("../vnode/handle-thunk.js");module.exports=createElement;function createElement(vnode,opts){var doc=opts?opts.document||document:document;var warn=opts?opts.warn:null;vnode=handleThunk(vnode).a;if(isWidget(vnode)){return vnode.init()}else if(isVText(vnode)){return doc.createTextNode(vnode.text)}else if(!isVNode(vnode)){if(warn){warn("Item is not a valid virtual dom node",vnode)}return null}var node=vnode.namespace===null?doc.createElement(vnode.tagName):doc.createElementNS(vnode.namespace,vnode.tagName);var props=vnode.properties;applyProperties(node,props);var children=vnode.children;for(var i=0;i<children.length;i++){var childNode=createElement(children[i],opts);if(childNode){node.appendChild(childNode)}}return node}},{"../vnode/handle-thunk.js":78,"../vnode/is-vnode.js":81,"../vnode/is-vtext.js":82,"../vnode/is-widget.js":83,"./apply-properties":68,"global/document":65}],70:[function(require,module,exports){var noChild={};module.exports=domIndex;function domIndex(rootNode,tree,indices,nodes){if(!indices||indices.length===0){return{}}else{indices.sort(ascending);return recurse(rootNode,tree,indices,nodes,0)}}function recurse(rootNode,tree,indices,nodes,rootIndex){nodes=nodes||{};if(rootNode){if(indexInRange(indices,rootIndex,rootIndex)){nodes[rootIndex]=rootNode}var vChildren=tree.children;if(vChildren){var childNodes=rootNode.childNodes;for(var i=0;i<tree.children.length;i++){rootIndex+=1;var vChild=vChildren[i]||noChild;var nextIndex=rootIndex+(vChild.count||0);if(indexInRange(indices,rootIndex,nextIndex)){recurse(childNodes[i],vChild,indices,nodes,rootIndex)}rootIndex=nextIndex}}}return nodes}function indexInRange(indices,left,right){if(indices.length===0){return false}var minIndex=0;var maxIndex=indices.length-1;var currentIndex;var currentItem;while(minIndex<=maxIndex){currentIndex=(maxIndex+minIndex)/2>>0;currentItem=indices[currentIndex];if(minIndex===maxIndex){return currentItem>=left&¤tItem<=right}else if(currentItem<left){minIndex=currentIndex+1}else if(currentItem>right){maxIndex=currentIndex-1}else{return true}}return false}function ascending(a,b){return a>b?1:-1}},{}],71:[function(require,module,exports){var applyProperties=require("./apply-properties");var isWidget=require("../vnode/is-widget.js");var VPatch=require("../vnode/vpatch.js");var render=require("./create-element");var updateWidget=require("./update-widget");module.exports=applyPatch;function applyPatch(vpatch,domNode,renderOptions){var type=vpatch.type;var vNode=vpatch.vNode;var patch=vpatch.patch;switch(type){case VPatch.REMOVE:return removeNode(domNode,vNode);case VPatch.INSERT:return insertNode(domNode,patch,renderOptions);case VPatch.VTEXT:return stringPatch(domNode,vNode,patch,renderOptions);case VPatch.WIDGET:return widgetPatch(domNode,vNode,patch,renderOptions);case VPatch.VNODE:return vNodePatch(domNode,vNode,patch,renderOptions);case VPatch.ORDER:reorderChildren(domNode,patch);return domNode;case VPatch.PROPS:applyProperties(domNode,patch,vNode.properties);return domNode;case VPatch.THUNK:return replaceRoot(domNode,renderOptions.patch(domNode,patch,renderOptions));default:return domNode}}function removeNode(domNode,vNode){var parentNode=domNode.parentNode;if(parentNode){parentNode.removeChild(domNode)}destroyWidget(domNode,vNode);return null}function insertNode(parentNode,vNode,renderOptions){var newNode=render(vNode,renderOptions);if(parentNode){parentNode.appendChild(newNode)}return parentNode}function stringPatch(domNode,leftVNode,vText,renderOptions){var newNode;if(domNode.nodeType===3){domNode.replaceData(0,domNode.length,vText.text);newNode=domNode}else{var parentNode=domNode.parentNode;newNode=render(vText,renderOptions);if(parentNode){parentNode.replaceChild(newNode,domNode)}}return newNode}function widgetPatch(domNode,leftVNode,widget,renderOptions){var updating=updateWidget(leftVNode,widget);var newNode;if(updating){newNode=widget.update(leftVNode,domNode)||domNode}else{newNode=render(widget,renderOptions)}var parentNode=domNode.parentNode;if(parentNode&&newNode!==domNode){parentNode.replaceChild(newNode,domNode)}if(!updating){destroyWidget(domNode,leftVNode)}return newNode}function vNodePatch(domNode,leftVNode,vNode,renderOptions){var parentNode=domNode.parentNode;var newNode=render(vNode,renderOptions);if(parentNode){parentNode.replaceChild(newNode,domNode)}return newNode}function destroyWidget(domNode,w){if(typeof w.destroy==="function"&&isWidget(w)){w.destroy(domNode)}}function reorderChildren(domNode,bIndex){var children=[];var childNodes=domNode.childNodes;var len=childNodes.length;var i;var reverseIndex=bIndex.reverse;for(i=0;i<len;i++){children.push(domNode.childNodes[i])}var insertOffset=0;var move;var node;var insertNode;var chainLength;var insertedLength;var nextSibling;for(i=0;i<len;){move=bIndex[i];chainLength=1;if(move!==undefined&&move!==i){while(bIndex[i+chainLength]===move+chainLength){chainLength++}if(reverseIndex[i]>i+chainLength){insertOffset++}node=children[move];insertNode=childNodes[i+insertOffset]||null;insertedLength=0;while(node!==insertNode&&insertedLength++<chainLength){domNode.insertBefore(node,insertNode);node=children[move+insertedLength]}if(move+chainLength<i){insertOffset--}}if(i in bIndex.removes){insertOffset++}i+=chainLength}}function replaceRoot(oldRoot,newRoot){if(oldRoot&&newRoot&&oldRoot!==newRoot&&oldRoot.parentNode){console.log(oldRoot);oldRoot.parentNode.replaceChild(newRoot,oldRoot)}return newRoot}},{"../vnode/is-widget.js":83,"../vnode/vpatch.js":86,"./apply-properties":68,"./create-element":69,"./update-widget":73}],72:[function(require,module,exports){var document=require("global/document");var isArray=require("x-is-array");var domIndex=require("./dom-index");var patchOp=require("./patch-op");module.exports=patch;function patch(rootNode,patches){return patchRecursive(rootNode,patches)}function patchRecursive(rootNode,patches,renderOptions){var indices=patchIndices(patches);if(indices.length===0){return rootNode}var index=domIndex(rootNode,patches.a,indices);var ownerDocument=rootNode.ownerDocument;if(!renderOptions){renderOptions={patch:patchRecursive};if(ownerDocument!==document){renderOptions.document=ownerDocument}}for(var i=0;i<indices.length;i++){var nodeIndex=indices[i];rootNode=applyPatch(rootNode,index[nodeIndex],patches[nodeIndex],renderOptions)}return rootNode}function applyPatch(rootNode,domNode,patchList,renderOptions){if(!domNode){return rootNode}var newNode;if(isArray(patchList)){for(var i=0;i<patchList.length;i++){newNode=patchOp(patchList[i],domNode,renderOptions);if(domNode===rootNode){rootNode=newNode}}}else{newNode=patchOp(patchList,domNode,renderOptions);if(domNode===rootNode){rootNode=newNode}}return rootNode}function patchIndices(patches){var indices=[];for(var key in patches){if(key!=="a"){indices.push(Number(key))}}return indices}},{"./dom-index":70,"./patch-op":71,"global/document":65,"x-is-array":67}],73:[function(require,module,exports){var isWidget=require("../vnode/is-widget.js");module.exports=updateWidget;function updateWidget(a,b){if(isWidget(a)&&isWidget(b)){if("name"in a&&"name"in b){return a.id===b.id}else{return a.init===b.init}}return false}},{"../vnode/is-widget.js":83}],74:[function(require,module,exports){"use strict";var EvStore=require("ev-store");module.exports=EvHook;function EvHook(value){if(!(this instanceof EvHook)){return new EvHook(value)}this.value=value}EvHook.prototype.hook=function(node,propertyName){var es=EvStore(node);var propName=propertyName.substr(3);es[propName]=this.value};EvHook.prototype.unhook=function(node,propertyName){var es=EvStore(node);var propName=propertyName.substr(3);es[propName]=undefined}},{"ev-store":62}],75:[function(require,module,exports){"use strict";module.exports=SoftSetHook;function SoftSetHook(value){if(!(this instanceof SoftSetHook)){return new SoftSetHook(value)}this.value=value}SoftSetHook.prototype.hook=function(node,propertyName){if(node[propertyName]!==this.value){node[propertyName]=this.value}}},{}],76:[function(require,module,exports){"use strict";var isArray=require("x-is-array");var VNode=require("../vnode/vnode.js");var VText=require("../vnode/vtext.js");var isVNode=require("../vnode/is-vnode");var isVText=require("../vnode/is-vtext");var isWidget=require("../vnode/is-widget");var isHook=require("../vnode/is-vhook");var isVThunk=require("../vnode/is-thunk");var parseTag=require("./parse-tag.js");var softSetHook=require("./hooks/soft-set-hook.js");var evHook=require("./hooks/ev-hook.js");module.exports=h;function h(tagName,properties,children){var childNodes=[];var tag,props,key,namespace;if(!children&&isChildren(properties)){children=properties;props={}}props=props||properties||{};tag=parseTag(tagName,props);if(props.hasOwnProperty("key")){key=props.key;props.key=undefined}if(props.hasOwnProperty("namespace")){namespace=props.namespace;props.namespace=undefined}if(tag==="INPUT"&&!namespace&&props.hasOwnProperty("value")&&props.value!==undefined&&!isHook(props.value)){props.value=softSetHook(props.value)}transformProperties(props);if(children!==undefined&&children!==null){addChild(children,childNodes,tag,props)}return new VNode(tag,props,childNodes,key,namespace)}function addChild(c,childNodes,tag,props){if(typeof c==="string"){childNodes.push(new VText(c))}else if(isChild(c)){childNodes.push(c)}else if(isArray(c)){for(var i=0;i<c.length;i++){addChild(c[i],childNodes,tag,props)}}else if(c===null||c===undefined){return}else{throw UnexpectedVirtualElement({foreignObject:c,parentVnode:{tagName:tag,properties:props}})}}function transformProperties(props){for(var propName in props){if(props.hasOwnProperty(propName)){var value=props[propName];if(isHook(value)){continue}if(propName.substr(0,3)==="ev-"){props[propName]=evHook(value)}}}}function isChild(x){return isVNode(x)||isVText(x)||isWidget(x)||isVThunk(x)}function isChildren(x){return typeof x==="string"||isArray(x)||isChild(x)}function UnexpectedVirtualElement(data){var err=new Error;err.type="virtual-hyperscript.unexpected.virtual-element";err.message="Unexpected virtual child passed to h().\n"+"Expected a VNode / Vthunk / VWidget / string but:\n"+"got:\n"+errorString(data.foreignObject)+".\n"+"The parent vnode is:\n"+errorString(data.parentVnode);"\n"+"Suggested fix: change your `h(..., [ ... ])` callsite.";err.foreignObject=data.foreignObject;err.parentVnode=data.parentVnode;return err}function errorString(obj){try{return JSON.stringify(obj,null," ")}catch(e){return String(obj)}}},{"../vnode/is-thunk":79,"../vnode/is-vhook":80,"../vnode/is-vnode":81,"../vnode/is-vtext":82,"../vnode/is-widget":83,"../vnode/vnode.js":85,"../vnode/vtext.js":87,"./hooks/ev-hook.js":74,"./hooks/soft-set-hook.js":75,"./parse-tag.js":77,"x-is-array":67}],77:[function(require,module,exports){"use strict";var split=require("browser-split");var classIdSplit=/([\.#]?[a-zA-Z0-9_:-]+)/;var notClassId=/^\.|#/;module.exports=parseTag;function parseTag(tag,props){if(!tag){return"DIV"}var noId=!props.hasOwnProperty("id");var tagParts=split(tag,classIdSplit);var tagName=null;if(notClassId.test(tagParts[1])){tagName="DIV"}var classes,part,type,i;for(i=0;i<tagParts.length;i++){part=tagParts[i];if(!part){continue}type=part.charAt(0);if(!tagName){tagName=part}else if(type==="."){classes=classes||[];classes.push(part.substring(1,part.length))}else if(type==="#"&&noId){props.id=part.substring(1,part.length)}}if(classes){if(props.className){classes.push(props.className)}props.className=classes.join(" ")}return props.namespace?tagName:tagName.toUpperCase()}},{"browser-split":61}],78:[function(require,module,exports){var isVNode=require("./is-vnode");var isVText=require("./is-vtext");var isWidget=require("./is-widget");var isThunk=require("./is-thunk");module.exports=handleThunk;function handleThunk(a,b){var renderedA=a;var renderedB=b;if(isThunk(b)){renderedB=renderThunk(b,a)}if(isThunk(a)){renderedA=renderThunk(a,null)}return{a:renderedA,b:renderedB}}function renderThunk(thunk,previous){var renderedThunk=thunk.vnode;if(!renderedThunk){renderedThunk=thunk.vnode=thunk.render(previous)}if(!(isVNode(renderedThunk)||isVText(renderedThunk)||isWidget(renderedThunk))){throw new Error("thunk did not return a valid node")}return renderedThunk}},{"./is-thunk":79,"./is-vnode":81,"./is-vtext":82,"./is-widget":83}],79:[function(require,module,exports){module.exports=isThunk;function isThunk(t){return t&&t.type==="Thunk"}},{}],80:[function(require,module,exports){module.exports=isHook;function isHook(hook){return hook&&(typeof hook.hook==="function"&&!hook.hasOwnProperty("hook")||typeof hook.unhook==="function"&&!hook.hasOwnProperty("unhook"))}},{}],81:[function(require,module,exports){var version=require("./version");module.exports=isVirtualNode;function isVirtualNode(x){return x&&x.type==="VirtualNode"&&x.version===version}},{"./version":84}],82:[function(require,module,exports){var version=require("./version");module.exports=isVirtualText;function isVirtualText(x){return x&&x.type==="VirtualText"&&x.version===version}},{"./version":84}],83:[function(require,module,exports){module.exports=isWidget;function isWidget(w){return w&&w.type==="Widget"}},{}],84:[function(require,module,exports){module.exports="1"},{}],85:[function(require,module,exports){var version=require("./version");var isVNode=require("./is-vnode");var isWidget=require("./is-widget");var isThunk=require("./is-thunk");var isVHook=require("./is-vhook");module.exports=VirtualNode;var noProperties={};var noChildren=[];function VirtualNode(tagName,properties,children,key,namespace){this.tagName=tagName;this.properties=properties||noProperties;this.children=children||noChildren;this.key=key!=null?String(key):undefined;this.namespace=typeof namespace==="string"?namespace:null;var count=children&&children.length||0;var descendants=0;var hasWidgets=false;var hasThunks=false;var descendantHooks=false;var hooks;for(var propName in properties){if(properties.hasOwnProperty(propName)){var property=properties[propName];if(isVHook(property)&&property.unhook){if(!hooks){hooks={}}hooks[propName]=property}}}for(var i=0;i<count;i++){var child=children[i];if(isVNode(child)){descendants+=child.count||0;if(!hasWidgets&&child.hasWidgets){hasWidgets=true}if(!hasThunks&&child.hasThunks){hasThunks=true}if(!descendantHooks&&(child.hooks||child.descendantHooks)){descendantHooks=true}}else if(!hasWidgets&&isWidget(child)){if(typeof child.destroy==="function"){hasWidgets=true}}else if(!hasThunks&&isThunk(child)){hasThunks=true}}this.count=count+descendants;this.hasWidgets=hasWidgets;this.hasThunks=hasThunks;this.hooks=hooks;this.descendantHooks=descendantHooks}VirtualNode.prototype.version=version;VirtualNode.prototype.type="VirtualNode"},{"./is-thunk":79,"./is-vhook":80,"./is-vnode":81,"./is-widget":83,"./version":84}],86:[function(require,module,exports){var version=require("./version");VirtualPatch.NONE=0;VirtualPatch.VTEXT=1;VirtualPatch.VNODE=2;VirtualPatch.WIDGET=3;VirtualPatch.PROPS=4;VirtualPatch.ORDER=5;VirtualPatch.INSERT=6;VirtualPatch.REMOVE=7;VirtualPatch.THUNK=8;module.exports=VirtualPatch;function VirtualPatch(type,vNode,patch){this.type=Number(type);this.vNode=vNode;this.patch=patch}VirtualPatch.prototype.version=version;VirtualPatch.prototype.type="VirtualPatch"},{"./version":84}],87:[function(require,module,exports){var version=require("./version");module.exports=VirtualText;function VirtualText(text){this.text=String(text)}VirtualText.prototype.version=version;VirtualText.prototype.type="VirtualText"},{"./version":84}],88:[function(require,module,exports){var isObject=require("is-object");var isHook=require("../vnode/is-vhook");module.exports=diffProps;function diffProps(a,b){var diff;for(var aKey in a){if(!(aKey in b)){diff=diff||{};diff[aKey]=undefined}var aValue=a[aKey];var bValue=b[aKey];if(aValue===bValue){continue}else if(isObject(aValue)&&isObject(bValue)){if(getPrototype(bValue)!==getPrototype(aValue)){diff=diff||{};diff[aKey]=bValue}else if(isHook(bValue)){diff=diff||{};diff[aKey]=bValue}else{var objectDiff=diffProps(aValue,bValue);if(objectDiff){diff=diff||{};diff[aKey]=objectDiff}}}else{diff=diff||{};diff[aKey]=bValue}}for(var bKey in b){if(!(bKey in a)){diff=diff||{};diff[bKey]=b[bKey]}}return diff}function getPrototype(value){if(Object.getPrototypeOf){return Object.getPrototypeOf(value)}else if(value.__proto__){return value.__proto__}else if(value.constructor){return value.constructor.prototype}}},{"../vnode/is-vhook":80,"is-object":66}],89:[function(require,module,exports){var isArray=require("x-is-array");var VPatch=require("../vnode/vpatch");var isVNode=require("../vnode/is-vnode");var isVText=require("../vnode/is-vtext");var isWidget=require("../vnode/is-widget");var isThunk=require("../vnode/is-thunk");var handleThunk=require("../vnode/handle-thunk");var diffProps=require("./diff-props");module.exports=diff;function diff(a,b){var patch={a:a};walk(a,b,patch,0);return patch}function walk(a,b,patch,index){if(a===b){return}var apply=patch[index];var applyClear=false;if(isThunk(a)||isThunk(b)){thunks(a,b,patch,index)}else if(b==null){if(!isWidget(a)){clearState(a,patch,index);apply=patch[index]}apply=appendPatch(apply,new VPatch(VPatch.REMOVE,a,b))}else if(isVNode(b)){if(isVNode(a)){if(a.tagName===b.tagName&&a.namespace===b.namespace&&a.key===b.key){var propsPatch=diffProps(a.properties,b.properties);if(propsPatch){apply=appendPatch(apply,new VPatch(VPatch.PROPS,a,propsPatch))}apply=diffChildren(a,b,patch,apply,index)}else{apply=appendPatch(apply,new VPatch(VPatch.VNODE,a,b));applyClear=true}}else{apply=appendPatch(apply,new VPatch(VPatch.VNODE,a,b));applyClear=true}}else if(isVText(b)){if(!isVText(a)){apply=appendPatch(apply,new VPatch(VPatch.VTEXT,a,b));applyClear=true}else if(a.text!==b.text){apply=appendPatch(apply,new VPatch(VPatch.VTEXT,a,b))}}else if(isWidget(b)){if(!isWidget(a)){applyClear=true}apply=appendPatch(apply,new VPatch(VPatch.WIDGET,a,b))}if(apply){patch[index]=apply}if(applyClear){clearState(a,patch,index)}}function diffChildren(a,b,patch,apply,index){var aChildren=a.children;var bChildren=reorder(aChildren,b.children);var aLen=aChildren.length;var bLen=bChildren.length;var len=aLen>bLen?aLen:bLen;for(var i=0;i<len;i++){var leftNode=aChildren[i];var rightNode=bChildren[i];index+=1;if(!leftNode){if(rightNode){apply=appendPatch(apply,new VPatch(VPatch.INSERT,null,rightNode))}}else{walk(leftNode,rightNode,patch,index)}if(isVNode(leftNode)&&leftNode.count){index+=leftNode.count}}if(bChildren.moves){apply=appendPatch(apply,new VPatch(VPatch.ORDER,a,bChildren.moves))}return apply}function clearState(vNode,patch,index){unhook(vNode,patch,index);destroyWidgets(vNode,patch,index)}function destroyWidgets(vNode,patch,index){if(isWidget(vNode)){if(typeof vNode.destroy==="function"){patch[index]=appendPatch(patch[index],new VPatch(VPatch.REMOVE,vNode,null))}}else if(isVNode(vNode)&&(vNode.hasWidgets||vNode.hasThunks)){var children=vNode.children;var len=children.length;for(var i=0;i<len;i++){var child=children[i];index+=1;destroyWidgets(child,patch,index);if(isVNode(child)&&child.count){index+=child.count}}}else if(isThunk(vNode)){thunks(vNode,null,patch,index)}}function thunks(a,b,patch,index){var nodes=handleThunk(a,b);var thunkPatch=diff(nodes.a,nodes.b);if(hasPatches(thunkPatch)){patch[index]=new VPatch(VPatch.THUNK,null,thunkPatch)}}function hasPatches(patch){for(var index in patch){if(index!=="a"){return true}}return false}function unhook(vNode,patch,index){if(isVNode(vNode)){if(vNode.hooks){patch[index]=appendPatch(patch[index],new VPatch(VPatch.PROPS,vNode,undefinedKeys(vNode.hooks)))}if(vNode.descendantHooks||vNode.hasThunks){var children=vNode.children;var len=children.length;for(var i=0;i<len;i++){var child=children[i];index+=1;unhook(child,patch,index);if(isVNode(child)&&child.count){index+=child.count}}}}else if(isThunk(vNode)){thunks(vNode,null,patch,index)}}function undefinedKeys(obj){var result={};for(var key in obj){result[key]=undefined}return result}function reorder(aChildren,bChildren){var bKeys=keyIndex(bChildren);if(!bKeys){return bChildren}var aKeys=keyIndex(aChildren);if(!aKeys){return bChildren}var bMatch={},aMatch={};for(var aKey in bKeys){bMatch[bKeys[aKey]]=aKeys[aKey]}for(var bKey in aKeys){aMatch[aKeys[bKey]]=bKeys[bKey]}var aLen=aChildren.length;var bLen=bChildren.length;var len=aLen>bLen?aLen:bLen;var shuffle=[];var freeIndex=0;var i=0;var moveIndex=0;var moves={};var removes=moves.removes={};var reverse=moves.reverse={};var hasMoves=false;while(freeIndex<len){var move=aMatch[i];if(move!==undefined){shuffle[i]=bChildren[move];if(move!==moveIndex){moves[move]=moveIndex;reverse[moveIndex]=move;hasMoves=true}moveIndex++}else if(i in aMatch){shuffle[i]=undefined;removes[i]=moveIndex++;hasMoves=true}else{while(bMatch[freeIndex]!==undefined){freeIndex++}if(freeIndex<len){var freeChild=bChildren[freeIndex];if(freeChild){shuffle[i]=freeChild;if(freeIndex!==moveIndex){hasMoves=true;moves[freeIndex]=moveIndex;reverse[moveIndex]=freeIndex}moveIndex++}freeIndex++}}i++}if(hasMoves){shuffle.moves=moves}return shuffle}function keyIndex(children){var i,keys;for(i=0;i<children.length;i++){var child=children[i];if(child.key!==undefined){keys=keys||{};keys[child.key]=i}}return keys}function appendPatch(apply,patch){if(apply){if(isArray(apply)){apply.push(patch)}else{apply=[apply,patch]}return apply}else{return patch}}},{"../vnode/handle-thunk":78,"../vnode/is-thunk":79,"../vnode/is-vnode":81,"../vnode/is-vtext":82,"../vnode/is-widget":83,"../vnode/vpatch":86,"./diff-props":88,"x-is-array":67}],90:[function(require,module,exports){arguments[4][39][0].apply(exports,arguments)},{dup:39}],91:[function(require,module,exports){module.exports=extend;function extend(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(source.hasOwnProperty(key)){target[key]=source[key]}}}return target}},{}],mercury:[function(require,module,exports){"use strict";var SingleEvent=require("geval/single");var MultipleEvent=require("geval/multiple");var extend=require("xtend");var mercury=module.exports={main:require("main-loop"),app:app,BaseEvent:require("value-event/base-event"),Delegator:require("dom-delegator"),input:input,handles:channels,channels:channels,event:require("value-event/event"),send:require("value-event/event"),valueEvent:require("value-event/value"),sendValue:require("value-event/value"),submitEvent:require("value-event/submit"),sendSubmit:require("value-event/submit"),changeEvent:require("value-event/change"),sendChange:require("value-event/change"),keyEvent:require("value-event/key"),sendKey:require("value-event/key"),clickEvent:require("value-event/click"),sendClick:require("value-event/click"),array:require("observ-array"),struct:require("observ-struct"),hash:require("observ-struct"),varhash:require("observ-varhash"),value:require("observ"),state:state,diff:require("virtual-dom/vtree/diff"),patch:require("virtual-dom/vdom/patch"),partial:require("vdom-thunk"),create:require("virtual-dom/vdom/create-element"),h:require("virtual-dom/virtual-hyperscript"),computed:require("observ/computed"),watch:require("observ/watch")};function input(names){if(!names){return SingleEvent()}return MultipleEvent(names); | |
}function state(obj){var copy=extend(obj);var $channels=copy.channels;var $handles=copy.handles;if($channels){copy.channels=mercury.value(null)}else if($handles){copy.handles=mercury.value(null)}var observ=mercury.struct(copy);if($channels){observ.channels.set(mercury.channels($channels,observ))}else if($handles){observ.handles.set(mercury.channels($handles,observ))}return observ}function channels(funcs,context){return Object.keys(funcs).reduce(createHandle,{});function createHandle(acc,name){var handle=mercury.Delegator.allocateHandle(funcs[name].bind(null,context));acc[name]=handle;return acc}}function app(elem,observ,render,opts){mercury.Delegator(opts);var loop=mercury.main(observ(),render,extend({diff:mercury.diff,create:mercury.create,patch:mercury.patch},opts));if(elem){elem.appendChild(loop.target)}return observ(loop.update)}},{"dom-delegator":5,"geval/multiple":18,"geval/single":19,"main-loop":20,observ:43,"observ-array":31,"observ-struct":38,"observ-varhash":40,"observ/computed":42,"observ/watch":44,"value-event/base-event":45,"value-event/change":46,"value-event/click":47,"value-event/event":48,"value-event/key":49,"value-event/submit":55,"value-event/value":56,"vdom-thunk":58,"virtual-dom/vdom/create-element":69,"virtual-dom/vdom/patch":72,"virtual-dom/virtual-hyperscript":76,"virtual-dom/vtree/diff":89,xtend:90}]},{},[]);"use strict";var immstruct=require("immstruct");var hg=require("mercury");var h=hg.h;var ctx=new AudioContext;var masterGain=ctx.createGain();masterGain.connect(ctx.destination);var osc=ctx.createOscillator();var structure=immstruct("modules",[{id:1,volume:.5,frequency:220,waveType:"sine"},{id:2,volume:.45,frequency:100,waveType:"triangle"}]);initSounds(structure);function initSounds(data){console.log(data);data.modules.forEach(function(module,index,array){var gain=ctx.createGain();var osc=ctx.createOscillator();gain.gain.value=module.volume;osc.frequency.value=module.frequency;osc.type=module.waveType;osc.connect(gain);gain.connect(masterGain);osc.start()})}function setPitch(state){}function App(){return hg.state({pitch:hg.value(150),channels:{updates:setPitch}})}function incrementCounter(state){state.value.set(state.value()+1)}App.render=function(state){return h("div.counter",["The state ",h("code","clickCount")," has value: "+state.pitch+".",h("input.button",{type:"button",value:"click me","ev-click":hg.send(state.channels.updates)})])};hg.app(document.body,App(),App.render); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"immstruct": "1.4.1", | |
"mercury": "14.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <body> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment