{"version":3,"file":"ractive.min.js","sources":["ractive.js"],"sourcesContent":["/*\n\tRactive.js v0.9.0-edge\n\tFri Dec 02 2016 17:14:38 GMT+0000 (UTC) - commit 6b8176217a75b19b96b6459d6f6ac3d49e126ea8\n\n\thttp://ractivejs.org\n\thttp://twitter.com/RactiveJS\n\n\tReleased under the MIT License.\n*/\n\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t((function() { var current = global.Ractive; var next = factory(); next.noConflict = function() { global.Ractive = current; return next; }; return global.Ractive = next; })());\n}(this, (function () { 'use strict';\n\nvar defaults = {\n\t// render placement:\n\tel: void 0,\n\tappend:\t\t\t\t false,\n\n\t// template:\n\ttemplate: null,\n\n\t// parse:\n\tdelimiters: [ '{{', '}}' ],\n\ttripleDelimiters: [ '{{{', '}}}' ],\n\tstaticDelimiters: [ '[[', ']]' ],\n\tstaticTripleDelimiters: [ '[[[', ']]]' ],\n\tcsp: \t\t\t\t\ttrue,\n\tinterpolate: false,\n\tpreserveWhitespace: false,\n\tsanitize: false,\n\tstripComments: true,\n\tcontextLines: 0,\n\n\t// data & binding:\n\tdata: {},\n\tcomputed: {},\n\tsyncComputedChildren: false,\n\tresolveInstanceMembers: true,\n\twarnAboutAmbiguity: false,\n\tmagic: false,\n\tmodifyArrays: false,\n\tadapt: [],\n\tisolated: false,\n\ttwoway: true,\n\tlazy: false,\n\n\t// transitions:\n\tnoIntro: false,\n\tnoOutro: false,\n\ttransitionsEnabled: true,\n\tcomplete: void 0,\n\tnestedTransitions: true,\n\n\t// css:\n\tcss: null,\n\tnoCssTransform: false\n};\n\n// These are a subset of the easing equations found at\n// https://raw.github.com/danro/easing-js - license info\n// follows:\n\n// --------------------------------------------------\n// easing.js v0.5.4\n// Generic set of easing functions with AMD support\n// https://github.com/danro/easing-js\n// This code may be freely distributed under the MIT license\n// http://danro.mit-license.org/\n// --------------------------------------------------\n// All functions adapted from Thomas Fuchs & Jeremy Kahn\n// Easing Equations (c) 2003 Robert Penner, BSD license\n// https://raw.github.com/danro/easing-js/master/LICENSE\n// --------------------------------------------------\n\n// In that library, the functions named easeIn, easeOut, and\n// easeInOut below are named easeInCubic, easeOutCubic, and\n// (you guessed it) easeInOutCubic.\n//\n// You can add additional easing functions to this list, and they\n// will be globally available.\n\n\nvar easing = {\n\tlinear: function linear ( pos ) { return pos; },\n\teaseIn: function easeIn ( pos ) { return Math.pow( pos, 3 ); },\n\teaseOut: function easeOut ( pos ) { return ( Math.pow( ( pos - 1 ), 3 ) + 1 ); },\n\teaseInOut: function easeInOut ( pos ) {\n\t\tif ( ( pos /= 0.5 ) < 1 ) { return ( 0.5 * Math.pow( pos, 3 ) ); }\n\t\treturn ( 0.5 * ( Math.pow( ( pos - 2 ), 3 ) + 2 ) );\n\t}\n};\n\nvar legacy = null;\n\n/* global console, navigator */\n/* eslint no-console:\"off\" */\n\nvar win = typeof window !== 'undefined' ? window : null;\nvar doc = win ? document : null;\n\nvar isClient = !!doc;\nvar isJsdom = ( typeof navigator !== 'undefined' && /jsDom/.test( navigator.appName ) );\nvar hasConsole = ( typeof console !== 'undefined' && typeof console.warn === 'function' && typeof console.warn.apply === 'function' );\n\nvar magic;\ntry {\n\tObject.defineProperty({}, 'test', { value: 0 });\n\tmagic = true;\n} catch ( e ) {\n\tmagic = false;\n}\n\nvar svg = doc ?\n\tdoc.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1' ) :\n\tfalse;\n\nvar vendors = [ 'o', 'ms', 'moz', 'webkit' ];\n\nvar html = 'http://www.w3.org/1999/xhtml';\nvar mathml = 'http://www.w3.org/1998/Math/MathML';\nvar svg$1 = 'http://www.w3.org/2000/svg';\nvar xlink = 'http://www.w3.org/1999/xlink';\nvar xml = 'http://www.w3.org/XML/1998/namespace';\nvar xmlns = 'http://www.w3.org/2000/xmlns';\n\nvar namespaces = { html: html, mathml: mathml, svg: svg$1, xlink: xlink, xml: xml, xmlns: xmlns };\n\nvar createElement;\nvar matches;\nvar div;\nvar methodNames;\nvar unprefixed;\nvar prefixed;\nvar i;\nvar j;\nvar makeFunction;\n\n// Test for SVG support\nif ( !svg ) {\n\tcreateElement = function ( type, ns, extend ) {\n\t\tif ( ns && ns !== html ) {\n\t\t\tthrow 'This browser does not support namespaces other than http://www.w3.org/1999/xhtml. The most likely cause of this error is that you\\'re trying to render SVG in an older browser. See http://docs.ractivejs.org/latest/svg-and-older-browsers for more information';\n\t\t}\n\n\t\treturn extend ?\n\t\t\tdoc.createElement( type, extend ) :\n\t\t\tdoc.createElement( type );\n\t};\n} else {\n\tcreateElement = function ( type, ns, extend ) {\n\t\tif ( !ns || ns === html ) {\n\t\t\treturn extend ?\n\t\t\t\tdoc.createElement( type, extend ) :\n\t\t\t\tdoc.createElement( type );\n\t\t}\n\n\t\treturn extend ?\n\t\t\tdoc.createElementNS( ns, type, extend ) :\n\t\t\tdoc.createElementNS( ns, type );\n\t};\n}\n\nfunction createDocumentFragment () {\n\treturn doc.createDocumentFragment();\n}\n\nfunction getElement ( input ) {\n\tvar output;\n\n\tif ( !input || typeof input === 'boolean' ) { return; }\n\n\tif ( !win || !doc || !input ) {\n\t\treturn null;\n\t}\n\n\t// We already have a DOM node - no work to do. (Duck typing alert!)\n\tif ( input.nodeType ) {\n\t\treturn input;\n\t}\n\n\t// Get node from string\n\tif ( typeof input === 'string' ) {\n\t\t// try ID first\n\t\toutput = doc.getElementById( input );\n\n\t\t// then as selector, if possible\n\t\tif ( !output && doc.querySelector ) {\n\t\t\toutput = doc.querySelector( input );\n\t\t}\n\n\t\t// did it work?\n\t\tif ( output && output.nodeType ) {\n\t\t\treturn output;\n\t\t}\n\t}\n\n\t// If we've been given a collection (jQuery, Zepto etc), extract the first item\n\tif ( input[0] && input[0].nodeType ) {\n\t\treturn input[0];\n\t}\n\n\treturn null;\n}\n\nif ( !isClient ) {\n\tmatches = null;\n} else {\n\tdiv = createElement( 'div' );\n\tmethodNames = [ 'matches', 'matchesSelector' ];\n\n\tmakeFunction = function ( methodName ) {\n\t\treturn function ( node, selector ) {\n\t\t\treturn node[ methodName ]( selector );\n\t\t};\n\t};\n\n\ti = methodNames.length;\n\n\twhile ( i-- && !matches ) {\n\t\tunprefixed = methodNames[i];\n\n\t\tif ( div[ unprefixed ] ) {\n\t\t\tmatches = makeFunction( unprefixed );\n\t\t} else {\n\t\t\tj = vendors.length;\n\t\t\twhile ( j-- ) {\n\t\t\t\tprefixed = vendors[i] + unprefixed.substr( 0, 1 ).toUpperCase() + unprefixed.substring( 1 );\n\n\t\t\t\tif ( div[ prefixed ] ) {\n\t\t\t\t\tmatches = makeFunction( prefixed );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// IE8...\n\tif ( !matches ) {\n\t\tmatches = function ( node, selector ) {\n\t\t\tvar parentNode, i;\n\n\t\t\tparentNode = node.parentNode;\n\n\t\t\tif ( !parentNode ) {\n\t\t\t\t// empty dummy
\n\t\t\t\tdiv.innerHTML = '';\n\n\t\t\t\tparentNode = div;\n\t\t\t\tnode = node.cloneNode();\n\n\t\t\t\tdiv.appendChild( node );\n\t\t\t}\n\n\t\t\tvar nodes = parentNode.querySelectorAll( selector );\n\n\t\t\ti = nodes.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( nodes[i] === node ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t};\n\t}\n}\n\nfunction detachNode ( node ) {\n\t// stupid ie\n\tif ( node && typeof node.parentNode !== 'unknown' && node.parentNode ) { // eslint-disable-line valid-typeof\n\t\tnode.parentNode.removeChild( node );\n\t}\n\n\treturn node;\n}\n\nfunction safeToStringValue ( value ) {\n\treturn ( value == null || !value.toString ) ? '' : '' + value;\n}\n\nfunction safeAttributeString ( string ) {\n\treturn safeToStringValue( string )\n\t\t.replace( /&/g, '&' )\n\t\t.replace( /\"/g, '"' )\n\t\t.replace( /'/g, ''' );\n}\n\nvar create;\nvar defineProperty;\nvar defineProperties;\n\ntry {\n\tObject.defineProperty({}, 'test', { get: function get() {}, set: function set() {} });\n\n\tif ( doc ) {\n\t\tObject.defineProperty( createElement( 'div' ), 'test', { value: 0 });\n\t}\n\n\tdefineProperty = Object.defineProperty;\n} catch ( err ) {\n\t// Object.defineProperty doesn't exist, or we're in IE8 where you can\n\t// only use it with DOM objects (what were you smoking, MSFT?)\n\tdefineProperty = function ( obj, prop, desc ) {\n\t\tif ( desc.get ) { obj[ prop ] = desc.get(); }\n\t\telse { obj[ prop ] = desc.value; }\n\t};\n}\n\ntry {\n\ttry {\n\t\tObject.defineProperties({}, { test: { value: 0 } });\n\t} catch ( err ) {\n\t\t// TODO how do we account for this? noMagic = true;\n\t\tthrow err;\n\t}\n\n\tif ( doc ) {\n\t\tObject.defineProperties( createElement( 'div' ), { test: { value: 0 } });\n\t}\n\n\tdefineProperties = Object.defineProperties;\n} catch ( err ) {\n\tdefineProperties = function ( obj, props ) {\n\t\tvar prop;\n\n\t\tfor ( prop in props ) {\n\t\t\tif ( props.hasOwnProperty( prop ) ) {\n\t\t\t\tdefineProperty( obj, prop, props[ prop ] );\n\t\t\t}\n\t\t}\n\t};\n}\n\ntry {\n\tObject.create( null );\n\n\tcreate = Object.create;\n} catch ( err ) {\n\t// sigh\n\tcreate = (function () {\n\t\tvar F = function () {};\n\n\t\treturn function ( proto, props ) {\n\t\t\tif ( proto === null ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tF.prototype = proto;\n\t\t\tvar obj = new F();\n\n\t\t\tif ( props ) {\n\t\t\t\tObject.defineProperties( obj, props );\n\t\t\t}\n\n\t\t\treturn obj;\n\t\t};\n\t}());\n}\n\nfunction extend$1 ( target ) {\n\tvar sources = [], len = arguments.length - 1;\n\twhile ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];\n\n\tvar prop;\n\n\tsources.forEach( function (source) {\n\t\tfor ( prop in source ) {\n\t\t\tif ( hasOwn.call( source, prop ) ) {\n\t\t\t\ttarget[ prop ] = source[ prop ];\n\t\t\t}\n\t\t}\n\t});\n\n\treturn target;\n}\n\nfunction fillGaps ( target ) {\n\tvar sources = [], len = arguments.length - 1;\n\twhile ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];\n\n\tsources.forEach( function (s) {\n\t\tfor ( var key in s ) {\n\t\t\tif ( hasOwn.call( s, key ) && !( key in target ) ) {\n\t\t\t\ttarget[ key ] = s[ key ];\n\t\t\t}\n\t\t}\n\t});\n\n\treturn target;\n}\n\nvar hasOwn = Object.prototype.hasOwnProperty;\n\nfunction toPairs ( obj ) {\n\tif ( obj === void 0 ) obj = {};\n\n\tvar res = [];\n\tfor ( var k in obj ) {\n\t\tif ( hasOwn.call( obj, k ) ) { res.push( [ k, obj[k] ] ); }\n\t}\n\treturn res;\n}\n\nvar toString$1$1 = Object.prototype.toString;\n// thanks, http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/\nfunction isArray ( thing ) {\n\treturn toString$1$1.call( thing ) === '[object Array]';\n}\n\n\n\nfunction isEqual ( a, b ) {\n\tif ( a === null && b === null ) {\n\t\treturn true;\n\t}\n\n\tif ( typeof a === 'object' || typeof b === 'object' ) {\n\t\treturn false;\n\t}\n\n\treturn a === b;\n}\n\n// http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric\nfunction isNumeric ( thing ) {\n\treturn !isNaN( parseFloat( thing ) ) && isFinite( thing );\n}\n\nfunction isObject ( thing ) {\n\treturn ( thing && toString$1$1.call( thing ) === '[object Object]' );\n}\n\nfunction isObjectLike ( thing ) {\n\tif ( !thing ) { return false; }\n\tvar type = typeof thing;\n\tif ( type === 'object' || type === 'function' ) { return true; }\n}\n\nvar noop = function () {};\n\n/* global console */\n/* eslint no-console:\"off\" */\n\nvar alreadyWarned = {};\nvar log;\nvar printWarning;\nvar welcome;\n\nif ( hasConsole ) {\n\tvar welcomeIntro = [\n\t\t\"%cRactive.js %c0.9.0-edge-6b8176217a75b19b96b6459d6f6ac3d49e126ea8 %cin debug mode, %cmore...\",\n\t\t'color: rgb(114, 157, 52); font-weight: normal;',\n\t\t'color: rgb(85, 85, 85); font-weight: normal;',\n\t\t'color: rgb(85, 85, 85); font-weight: normal;',\n\t\t'color: rgb(82, 140, 224); font-weight: normal; text-decoration: underline;'\n\t];\n\tvar welcomeMessage = \"You're running Ractive 0.9.0-edge-6b8176217a75b19b96b6459d6f6ac3d49e126ea8 in debug mode - messages will be printed to the console to help you fix problems and optimise your application.\\n\\nTo disable debug mode, add this line at the start of your app:\\n Ractive.DEBUG = false;\\n\\nTo disable debug mode when your app is minified, add this snippet:\\n Ractive.DEBUG = /unminified/.test(function(){/*unminified*/});\\n\\nGet help and support:\\n http://docs.ractivejs.org\\n http://stackoverflow.com/questions/tagged/ractivejs\\n http://groups.google.com/forum/#!forum/ractive-js\\n http://twitter.com/ractivejs\\n\\nFound a bug? Raise an issue:\\n https://github.com/ractivejs/ractive/issues\\n\\n\";\n\n\twelcome = function () {\n\t\tif ( Ractive.WELCOME_MESSAGE === false ) {\n\t\t\twelcome = noop;\n\t\t\treturn;\n\t\t}\n\t\tvar message = 'WELCOME_MESSAGE' in Ractive ? Ractive.WELCOME_MESSAGE : welcomeMessage;\n\t\tvar hasGroup = !!console.groupCollapsed;\n\t\tif ( hasGroup ) { console.groupCollapsed.apply( console, welcomeIntro ); }\n\t\tconsole.log( message );\n\t\tif ( hasGroup ) {\n\t\t\tconsole.groupEnd( welcomeIntro );\n\t\t}\n\n\t\twelcome = noop;\n\t};\n\n\tprintWarning = function ( message, args ) {\n\t\twelcome();\n\n\t\t// extract information about the instance this message pertains to, if applicable\n\t\tif ( typeof args[ args.length - 1 ] === 'object' ) {\n\t\t\tvar options = args.pop();\n\t\t\tvar ractive = options ? options.ractive : null;\n\n\t\t\tif ( ractive ) {\n\t\t\t\t// if this is an instance of a component that we know the name of, add\n\t\t\t\t// it to the message\n\t\t\t\tvar name;\n\t\t\t\tif ( ractive.component && ( name = ractive.component.name ) ) {\n\t\t\t\t\tmessage = \"<\" + name + \"> \" + message;\n\t\t\t\t}\n\n\t\t\t\tvar node;\n\t\t\t\tif ( node = ( options.node || ( ractive.fragment && ractive.fragment.rendered && ractive.find( '*' ) ) ) ) {\n\t\t\t\t\targs.push( node );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconsole.warn.apply( console, [ '%cRactive.js: %c' + message, 'color: rgb(114, 157, 52);', 'color: rgb(85, 85, 85);' ].concat( args ) );\n\t};\n\n\tlog = function () {\n\t\tconsole.log.apply( console, arguments );\n\t};\n} else {\n\tprintWarning = log = welcome = noop;\n}\n\nfunction format ( message, args ) {\n\treturn message.replace( /%s/g, function () { return args.shift(); } );\n}\n\nfunction fatal ( message ) {\n\tvar args = [], len = arguments.length - 1;\n\twhile ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n\tmessage = format( message, args );\n\tthrow new Error( message );\n}\n\nfunction logIfDebug () {\n\tif ( Ractive.DEBUG ) {\n\t\tlog.apply( null, arguments );\n\t}\n}\n\nfunction warn ( message ) {\n\tvar args = [], len = arguments.length - 1;\n\twhile ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n\tmessage = format( message, args );\n\tprintWarning( message, args );\n}\n\nfunction warnOnce ( message ) {\n\tvar args = [], len = arguments.length - 1;\n\twhile ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n\tmessage = format( message, args );\n\n\tif ( alreadyWarned[ message ] ) {\n\t\treturn;\n\t}\n\n\talreadyWarned[ message ] = true;\n\tprintWarning( message, args );\n}\n\nfunction warnIfDebug () {\n\tif ( Ractive.DEBUG ) {\n\t\twarn.apply( null, arguments );\n\t}\n}\n\nfunction warnOnceIfDebug () {\n\tif ( Ractive.DEBUG ) {\n\t\twarnOnce.apply( null, arguments );\n\t}\n}\n\n// Error messages that are used (or could be) in multiple places\nvar badArguments = 'Bad arguments';\nvar noRegistryFunctionReturn = 'A function was specified for \"%s\" %s, but no %s was returned';\nvar missingPlugin = function ( name, type ) { return (\"Missing \\\"\" + name + \"\\\" \" + type + \" plugin. You may need to download a plugin via http://docs.ractivejs.org/latest/plugins#\" + type + \"s\"); };\n\nfunction findInViewHierarchy ( registryName, ractive, name ) {\n\tvar instance = findInstance( registryName, ractive, name );\n\treturn instance ? instance[ registryName ][ name ] : null;\n}\n\nfunction findInstance ( registryName, ractive, name ) {\n\twhile ( ractive ) {\n\t\tif ( name in ractive[ registryName ] ) {\n\t\t\treturn ractive;\n\t\t}\n\n\t\tif ( ractive.isolated ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tractive = ractive.parent;\n\t}\n}\n\nfunction interpolate ( from, to, ractive, type ) {\n\tif ( from === to ) { return null; }\n\n\tif ( type ) {\n\t\tvar interpol = findInViewHierarchy( 'interpolators', ractive, type );\n\t\tif ( interpol ) { return interpol( from, to ) || null; }\n\n\t\tfatal( missingPlugin( type, 'interpolator' ) );\n\t}\n\n\treturn interpolators.number( from, to ) ||\n\t interpolators.array( from, to ) ||\n\t interpolators.object( from, to ) ||\n\t null;\n}\n\nfunction snap ( to ) {\n\treturn function () { return to; };\n}\n\nvar interpolators = {\n\tnumber: function number ( from, to ) {\n\t\tif ( !isNumeric( from ) || !isNumeric( to ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfrom = +from;\n\t\tto = +to;\n\n\t\tvar delta = to - from;\n\n\t\tif ( !delta ) {\n\t\t\treturn function () { return from; };\n\t\t}\n\n\t\treturn function ( t ) {\n\t\t\treturn from + ( t * delta );\n\t\t};\n\t},\n\n\tarray: function array ( from, to ) {\n\t\tvar len, i;\n\n\t\tif ( !isArray( from ) || !isArray( to ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tvar intermediate = [];\n\t\tvar interpolators = [];\n\n\t\ti = len = Math.min( from.length, to.length );\n\t\twhile ( i-- ) {\n\t\t\tinterpolators[i] = interpolate( from[i], to[i] );\n\t\t}\n\n\t\t// surplus values - don't interpolate, but don't exclude them either\n\t\tfor ( i=len; i> j ) ? '*' : parts[j] );\n\t\t}\n\t\tresult.unshift( join.join( '.' ) );\n\t}\n\n\tif ( base ) {\n\t\t// include non-this-namespaced versions\n\t\tif ( parts.length > 2 ) {\n\t\t\tresult.push.apply( result, variants( name, false ) );\n\t\t} else {\n\t\t\tresult.push( '*' );\n\t\t\tresult.push( name );\n\t\t}\n\t}\n\n\tmap[ name ] = result;\n\treturn result;\n}\n\nfunction fireEvent ( ractive, eventName, options ) {\n\tif ( options === void 0 ) options = {};\n\n\tif ( !eventName ) { return; }\n\n\tif ( !options.event ) {\n\t\toptions.event = {\n\t\t\tname: eventName,\n\t\t\t// until event not included as argument default\n\t\t\t_noArg: true\n\t\t};\n\t} else {\n\t\toptions.event.name = eventName;\n\t}\n\n\tvar eventNames = variants( eventName, true );\n\n\treturn fireEventAs( ractive, eventNames, options.event, options.args, true );\n}\n\nfunction fireEventAs ( ractive, eventNames, event, args, initialFire ) {\n\tif ( initialFire === void 0 ) initialFire = false;\n\n\tvar subscribers, i;\n\tvar bubble = true;\n\n\tenqueue( ractive, event );\n\n\tfor ( i = eventNames.length; i >= 0; i-- ) {\n\t\tsubscribers = ractive._subs[ eventNames[ i ] ];\n\n\t\tif ( subscribers ) {\n\t\t\tbubble = notifySubscribers( ractive, subscribers, event, args ) && bubble;\n\t\t}\n\t}\n\n\tdequeue( ractive );\n\n\tif ( ractive.parent && bubble ) {\n\n\t\tif ( initialFire && ractive.component ) {\n\t\t\tvar fullName = ractive.component.name + '.' + eventNames[ eventNames.length - 1 ];\n\t\t\teventNames = variants( fullName, false );\n\n\t\t\tif ( event && !event.component ) {\n\t\t\t\tevent.component = ractive;\n\t\t\t}\n\t\t}\n\n\t\tfireEventAs( ractive.parent, eventNames, event, args );\n\t}\n\n\treturn bubble;\n}\n\nfunction notifySubscribers ( ractive, subscribers, event, args ) {\n\tvar originalEvent = null;\n\tvar stopEvent = false;\n\n\tif ( event && !event._noArg ) {\n\t\targs = [ event ].concat( args );\n\t}\n\n\t// subscribers can be modified inflight, e.g. \"once\" functionality\n\t// so we need to copy to make sure everyone gets called\n\tsubscribers = subscribers.slice();\n\n\tfor ( var i = 0, len = subscribers.length; i < len; i += 1 ) {\n\t\tif ( !subscribers[ i ].off && subscribers[ i ].apply( ractive, args ) === false ) {\n\t\t\tstopEvent = true;\n\t\t}\n\t}\n\n\tif ( event && !event._noArg && stopEvent && ( originalEvent = event.original ) ) {\n\t\toriginalEvent.preventDefault && originalEvent.preventDefault();\n\t\toriginalEvent.stopPropagation && originalEvent.stopPropagation();\n\t}\n\n\treturn !stopEvent;\n}\n\nvar Hook = function Hook ( event ) {\n\tthis.event = event;\n\tthis.method = 'on' + event;\n};\n\nHook.prototype.fire = function fire ( ractive, arg ) {\n\tif ( ractive[ this.method ] ) {\n\t\targ ? ractive[ this.method ]( arg ) : ractive[ this.method ]();\n\t}\n\n\tvar options = { args: [] };\n\tif ( arg ) { options.args.push( arg ); }\n\toptions.args.push( ractive );\n\tfireEvent( ractive, this.event, options );\n};\n\nfunction addToArray ( array, value ) {\n\tvar index = array.indexOf( value );\n\n\tif ( index === -1 ) {\n\t\tarray.push( value );\n\t}\n}\n\nfunction arrayContains ( array, value ) {\n\tfor ( var i = 0, c = array.length; i < c; i++ ) {\n\t\tif ( array[i] == value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction arrayContentsMatch ( a, b ) {\n\tvar i;\n\n\tif ( !isArray( a ) || !isArray( b ) ) {\n\t\treturn false;\n\t}\n\n\tif ( a.length !== b.length ) {\n\t\treturn false;\n\t}\n\n\ti = a.length;\n\twhile ( i-- ) {\n\t\tif ( a[i] !== b[i] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction ensureArray ( x ) {\n\tif ( typeof x === 'string' ) {\n\t\treturn [ x ];\n\t}\n\n\tif ( x === undefined ) {\n\t\treturn [];\n\t}\n\n\treturn x;\n}\n\nfunction lastItem ( array ) {\n\treturn array[ array.length - 1 ];\n}\n\nfunction removeFromArray ( array, member ) {\n\tif ( !array ) {\n\t\treturn;\n\t}\n\n\tvar index = array.indexOf( member );\n\n\tif ( index !== -1 ) {\n\t\tarray.splice( index, 1 );\n\t}\n}\n\nfunction combine ( first ) {\n\tvar rest = [], len$1 = arguments.length - 1;\n\twhile ( len$1-- > 0 ) rest[ len$1 ] = arguments[ len$1 + 1 ];\n\n\tvar res = first.slice();\n\trest = rest.concat.apply( [], rest );\n\n\tvar len = rest.length;\n\tfor ( var i = 0; i < len; i++ ) {\n\t\tif ( !~res.indexOf( rest[i] ) ) {\n\t\t\tres.push( rest[i] );\n\t\t}\n\t}\n\n\treturn res;\n}\n\nfunction toArray ( arrayLike ) {\n\tvar array = [];\n\tvar i = arrayLike.length;\n\twhile ( i-- ) {\n\t\tarray[i] = arrayLike[i];\n\t}\n\n\treturn array;\n}\n\nfunction find$1 ( array, fn ) {\n\tvar len = array.length;\n\tfor ( var i = 0; i < len; i++ ) {\n\t\tif ( fn( array[i] ) ) { return array[i]; }\n\t}\n}\n\nfunction findMap ( array, fn ) {\n\tvar len = array.length;\n\tfor ( var i = 0; i < len; i++ ) {\n\t\tvar result = fn( array[i] );\n\t\tif ( result ) { return result; }\n\t}\n}\n\nvar _Promise;\nvar PENDING = {};\nvar FULFILLED = {};\nvar REJECTED = {};\n\nif ( typeof Promise === 'function' ) {\n\t// use native Promise\n\t_Promise = Promise;\n} else {\n\t_Promise = function ( callback ) {\n\t\tvar fulfilledHandlers = [];\n\t\tvar rejectedHandlers = [];\n\t\tvar state = PENDING;\n\t\tvar result, dispatchHandlers;\n\n\t\tvar makeResolver = function ( newState ) {\n\t\t\treturn function ( value ) {\n\t\t\t\tif ( state !== PENDING ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresult = value;\n\t\t\t\tstate = newState;\n\n\t\t\t\tdispatchHandlers = makeDispatcher( ( state === FULFILLED ? fulfilledHandlers : rejectedHandlers ), result );\n\n\t\t\t\t// dispatch onFulfilled and onRejected handlers asynchronously\n\t\t\t\twait( dispatchHandlers );\n\t\t\t};\n\t\t};\n\n\t\tvar fulfil = makeResolver( FULFILLED );\n\t\tvar reject = makeResolver( REJECTED );\n\n\t\ttry {\n\t\t\tcallback( fulfil, reject );\n\t\t} catch ( err ) {\n\t\t\treject( err );\n\t\t}\n\n\t\tvar promise = {\n\t\t\t// `then()` returns a Promise - 2.2.7\n\t\t\tthen: function then ( onFulfilled, onRejected ) {\n\t\t\t\tvar promise2 = new _Promise( function ( fulfil, reject ) {\n\n\t\t\t\t\tvar processResolutionHandler = function ( handler, handlers, forward ) {\n\n\t\t\t\t\t\t// 2.2.1.1\n\t\t\t\t\t\tif ( typeof handler === 'function' ) {\n\t\t\t\t\t\t\thandlers.push( function ( p1result ) {\n\t\t\t\t\t\t\t\tvar x;\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tx = handler( p1result );\n\t\t\t\t\t\t\t\t\tresolve$1( promise2, x, fulfil, reject );\n\t\t\t\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\t\t\t\treject( err );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Forward the result of promise1 to promise2, if resolution handlers\n\t\t\t\t\t\t\t// are not given\n\t\t\t\t\t\t\thandlers.push( forward );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// 2.2\n\t\t\t\t\tprocessResolutionHandler( onFulfilled, fulfilledHandlers, fulfil );\n\t\t\t\t\tprocessResolutionHandler( onRejected, rejectedHandlers, reject );\n\n\t\t\t\t\tif ( state !== PENDING ) {\n\t\t\t\t\t\t// If the promise has resolved already, dispatch the appropriate handlers asynchronously\n\t\t\t\t\t\twait( dispatchHandlers );\n\t\t\t\t\t}\n\n\t\t\t\t});\n\n\t\t\t\treturn promise2;\n\t\t\t}\n\t\t};\n\n\t\tpromise[ 'catch' ] = function ( onRejected ) {\n\t\t\treturn this.then( null, onRejected );\n\t\t};\n\n\t\treturn promise;\n\t};\n\n\t_Promise.all = function ( promises ) {\n\t\treturn new _Promise( function ( fulfil, reject ) {\n\t\t\tvar result = [];\n\t\t\tvar pending, i;\n\n\t\t\tif ( !promises.length ) {\n\t\t\t\tfulfil( result );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar processPromise = function ( promise, i ) {\n\t\t\t\tif ( promise && typeof promise.then === 'function' ) {\n\t\t\t\t\tpromise.then( function (value) {\n\t\t\t\t\t\tresult[i] = value;\n\t\t\t\t\t\t--pending || fulfil( result );\n\t\t\t\t\t}, reject );\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tresult[i] = promise;\n\t\t\t\t\t--pending || fulfil( result );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tpending = i = promises.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tprocessPromise( promises[i], i );\n\t\t\t}\n\t\t});\n\t};\n\n\t_Promise.resolve = function ( value ) {\n\t\treturn new _Promise( function ( fulfil ) {\n\t\t\tfulfil( value );\n\t\t});\n\t};\n\n\t_Promise.reject = function ( reason ) {\n\t\treturn new _Promise( function ( fulfil, reject ) {\n\t\t\treject( reason );\n\t\t});\n\t};\n}\n\nvar Promise$1 = _Promise;\n\n// TODO use MutationObservers or something to simulate setImmediate\nfunction wait ( callback ) {\n\tsetTimeout( callback, 0 );\n}\n\nfunction makeDispatcher ( handlers, result ) {\n\treturn function () {\n\t\tvar handler;\n\n\t\twhile ( handler = handlers.shift() ) {\n\t\t\thandler( result );\n\t\t}\n\t};\n}\n\nfunction resolve$1 ( promise, x, fulfil, reject ) {\n\t// Promise Resolution Procedure\n\tvar then;\n\n\t// 2.3.1\n\tif ( x === promise ) {\n\t\tthrow new TypeError( 'A promise\\'s fulfillment handler cannot return the same promise' );\n\t}\n\n\t// 2.3.2\n\tif ( x instanceof _Promise ) {\n\t\tx.then( fulfil, reject );\n\t}\n\n\t// 2.3.3\n\telse if ( x && ( typeof x === 'object' || typeof x === 'function' ) ) {\n\t\ttry {\n\t\t\tthen = x.then; // 2.3.3.1\n\t\t} catch ( e ) {\n\t\t\treject( e ); // 2.3.3.2\n\t\t\treturn;\n\t\t}\n\n\t\t// 2.3.3.3\n\t\tif ( typeof then === 'function' ) {\n\t\t\tvar called;\n\n\t\t\tvar resolvePromise = function ( y ) {\n\t\t\t\tif ( called ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcalled = true;\n\t\t\t\tresolve$1( promise, y, fulfil, reject );\n\t\t\t};\n\n\t\t\tvar rejectPromise = function ( r ) {\n\t\t\t\tif ( called ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcalled = true;\n\t\t\t\treject( r );\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tthen.call( x, resolvePromise, rejectPromise );\n\t\t\t} catch ( e ) {\n\t\t\t\tif ( !called ) { // 2.3.3.3.4.1\n\t\t\t\t\treject( e ); // 2.3.3.3.4.2\n\t\t\t\t\tcalled = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telse {\n\t\t\tfulfil( x );\n\t\t}\n\t}\n\n\telse {\n\t\tfulfil( x );\n\t}\n}\n\nvar TransitionManager = function TransitionManager ( callback, parent ) {\n\tthis.callback = callback;\n\tthis.parent = parent;\n\n\tthis.intros = [];\n\tthis.outros = [];\n\n\tthis.children = [];\n\tthis.totalChildren = this.outroChildren = 0;\n\n\tthis.detachQueue = [];\n\tthis.outrosComplete = false;\n\n\tif ( parent ) {\n\t\tparent.addChild( this );\n\t}\n};\n\nTransitionManager.prototype.add = function add ( transition ) {\n\tvar list = transition.isIntro ? this.intros : this.outros;\n\ttransition.starting = true;\n\tlist.push( transition );\n};\n\nTransitionManager.prototype.addChild = function addChild ( child ) {\n\tthis.children.push( child );\n\n\tthis.totalChildren += 1;\n\tthis.outroChildren += 1;\n};\n\nTransitionManager.prototype.decrementOutros = function decrementOutros () {\n\tthis.outroChildren -= 1;\n\tcheck( this );\n};\n\nTransitionManager.prototype.decrementTotal = function decrementTotal () {\n\tthis.totalChildren -= 1;\n\tcheck( this );\n};\n\nTransitionManager.prototype.detachNodes = function detachNodes () {\n\tthis.detachQueue.forEach( detach$1 );\n\tthis.children.forEach( _detachNodes );\n};\n\nTransitionManager.prototype.ready = function ready () {\n\tdetachImmediate( this );\n};\n\nTransitionManager.prototype.remove = function remove ( transition ) {\n\tvar list = transition.isIntro ? this.intros : this.outros;\n\tremoveFromArray( list, transition );\n\tcheck( this );\n};\n\nTransitionManager.prototype.start = function start () {\n\tthis.children.forEach( function (c) { return c.start(); } );\n\tthis.intros.concat( this.outros ).forEach( function (t) { return t.start(); } );\n\tthis.ready = true;\n\tcheck( this );\n};\n\nfunction detach$1 ( element ) {\n\telement.detach();\n}\n\nfunction _detachNodes ( tm ) { // _ to avoid transpiler quirk\n\ttm.detachNodes();\n}\n\nfunction check ( tm ) {\n\tif ( !tm.ready || tm.outros.length || tm.outroChildren ) { return; }\n\n\t// If all outros are complete, and we haven't already done this,\n\t// we notify the parent if there is one, otherwise\n\t// start detaching nodes\n\tif ( !tm.outrosComplete ) {\n\t\ttm.outrosComplete = true;\n\n\t\tif ( tm.parent && !tm.parent.outrosComplete ) {\n\t\t\ttm.parent.decrementOutros( tm );\n\t\t} else {\n\t\t\ttm.detachNodes();\n\t\t}\n\t}\n\n\t// Once everything is done, we can notify parent transition\n\t// manager and call the callback\n\tif ( !tm.intros.length && !tm.totalChildren ) {\n\t\tif ( typeof tm.callback === 'function' ) {\n\t\t\ttm.callback();\n\t\t}\n\n\t\tif ( tm.parent && !tm.notifiedTotal ) {\n\t\t\ttm.notifiedTotal = true;\n\t\t\ttm.parent.decrementTotal();\n\t\t}\n\t}\n}\n\n// check through the detach queue to see if a node is up or downstream from a\n// transition and if not, go ahead and detach it\nfunction detachImmediate ( manager ) {\n\tvar queue = manager.detachQueue;\n\tvar outros = collectAllOutros( manager );\n\n\tvar i = queue.length;\n\tvar j = 0;\n\tvar node, trans;\n\tstart: while ( i-- ) {\n\t\tnode = queue[i].node;\n\t\tj = outros.length;\n\t\twhile ( j-- ) {\n\t\t\ttrans = outros[j].element.node;\n\t\t\t// check to see if the node is, contains, or is contained by the transitioning node\n\t\t\tif ( trans === node || trans.contains( node ) || node.contains( trans ) ) { continue start; }\n\t\t}\n\n\t\t// no match, we can drop it\n\t\tqueue[i].detach();\n\t\tqueue.splice( i, 1 );\n\t}\n}\n\nfunction collectAllOutros ( manager, list ) {\n\tif ( !list ) {\n\t\tlist = [];\n\t\tvar parent = manager;\n\t\twhile ( parent.parent ) { parent = parent.parent; }\n\t\treturn collectAllOutros( parent, list );\n\t} else {\n\t\tvar i = manager.children.length;\n\t\twhile ( i-- ) {\n\t\t\tlist = collectAllOutros( manager.children[i], list );\n\t\t}\n\t\tlist = list.concat( manager.outros );\n\t\treturn list;\n\t}\n}\n\nvar changeHook = new Hook( 'change' );\n\nvar batch;\n\nvar runloop = {\n\tstart: function start ( instance ) {\n\t\tvar fulfilPromise;\n\t\tvar promise = new Promise$1( function (f) { return ( fulfilPromise = f ); } );\n\n\t\tbatch = {\n\t\t\tpreviousBatch: batch,\n\t\t\ttransitionManager: new TransitionManager( fulfilPromise, batch && batch.transitionManager ),\n\t\t\tfragments: [],\n\t\t\ttasks: [],\n\t\t\timmediateObservers: [],\n\t\t\tdeferredObservers: [],\n\t\t\tractives: [],\n\t\t\tinstance: instance,\n\t\t\tpromise: promise\n\t\t};\n\n\t\treturn promise;\n\t},\n\n\tend: function end () {\n\t\tflushChanges();\n\n\t\tif ( !batch.previousBatch ) { batch.transitionManager.start(); }\n\n\t\tbatch = batch.previousBatch;\n\t},\n\n\taddFragment: function addFragment ( fragment ) {\n\t\taddToArray( batch.fragments, fragment );\n\t},\n\n\t// TODO: come up with a better way to handle fragments that trigger their own update\n\taddFragmentToRoot: function addFragmentToRoot ( fragment ) {\n\t\tif ( !batch ) { return; }\n\n\t\tvar b = batch;\n\t\twhile ( b.previousBatch ) {\n\t\t\tb = b.previousBatch;\n\t\t}\n\n\t\taddToArray( b.fragments, fragment );\n\t},\n\n\taddInstance: function addInstance ( instance ) {\n\t\tif ( batch ) { addToArray( batch.ractives, instance ); }\n\t},\n\n\taddObserver: function addObserver ( observer, defer ) {\n\t\taddToArray( defer ? batch.deferredObservers : batch.immediateObservers, observer );\n\t},\n\n\tregisterTransition: function registerTransition ( transition ) {\n\t\ttransition._manager = batch.transitionManager;\n\t\tbatch.transitionManager.add( transition );\n\t},\n\n\t// synchronise node detachments with transition ends\n\tdetachWhenReady: function detachWhenReady ( thing ) {\n\t\tbatch.transitionManager.detachQueue.push( thing );\n\t},\n\n\tscheduleTask: function scheduleTask ( task, postRender ) {\n\t\tvar _batch;\n\n\t\tif ( !batch ) {\n\t\t\ttask();\n\t\t} else {\n\t\t\t_batch = batch;\n\t\t\twhile ( postRender && _batch.previousBatch ) {\n\t\t\t\t// this can't happen until the DOM has been fully updated\n\t\t\t\t// otherwise in some situations (with components inside elements)\n\t\t\t\t// transitions and decorators will initialise prematurely\n\t\t\t\t_batch = _batch.previousBatch;\n\t\t\t}\n\n\t\t\t_batch.tasks.push( task );\n\t\t}\n\t},\n\n\tpromise: function promise () {\n\t\tif ( !batch ) { return Promise$1.resolve(); }\n\n\t\tvar target = batch;\n\t\twhile ( target.previousBatch ) {\n\t\t\ttarget = target.previousBatch;\n\t\t}\n\n\t\treturn target.promise || Promise$1.resolve();\n\t}\n};\n\nfunction dispatch$1 ( observer ) {\n\tobserver.dispatch();\n}\n\nfunction flushChanges () {\n\tvar which = batch.immediateObservers;\n\tbatch.immediateObservers = [];\n\twhich.forEach( dispatch$1 );\n\n\t// Now that changes have been fully propagated, we can update the DOM\n\t// and complete other tasks\n\tvar i = batch.fragments.length;\n\tvar fragment;\n\n\twhich = batch.fragments;\n\tbatch.fragments = [];\n\tvar ractives = batch.ractives;\n\tbatch.ractives = [];\n\n\twhile ( i-- ) {\n\t\tfragment = which[i];\n\n\t\t// TODO deprecate this. It's annoying and serves no useful function\n\t\tvar ractive = fragment.ractive;\n\t\tif ( Object.keys( ractive.viewmodel.changes ).length ) {\n\t\t\tchangeHook.fire( ractive, ractive.viewmodel.changes );\n\t\t}\n\t\tractive.viewmodel.changes = {};\n\t\tremoveFromArray( ractives, ractive );\n\n\t\tfragment.update();\n\t}\n\n\ti = ractives.length;\n\twhile ( i-- ) {\n\t\tvar ractive$1 = ractives[i];\n\t\tchangeHook.fire( ractive$1, ractive$1.viewmodel.changes );\n\t\tractive$1.viewmodel.changes = {};\n\t}\n\n\tbatch.transitionManager.ready();\n\n\twhich = batch.deferredObservers;\n\tbatch.deferredObservers = [];\n\twhich.forEach( dispatch$1 );\n\n\tvar tasks = batch.tasks;\n\tbatch.tasks = [];\n\n\tfor ( i = 0; i < tasks.length; i += 1 ) {\n\t\ttasks[i]();\n\t}\n\n\t// If updating the view caused some model blowback - e.g. a triple\n\t// containing