{"version":3,"file":"ractive-legacy.min.js","sources":["ractive-legacy.js"],"sourcesContent":["/*\n\tRactive.js v0.9.0-edge\n\tTue Nov 15 2016 20:11:47 GMT+0000 (UTC) - commit 16ab6a28cd037ae65308b32137032525cd096c8a\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\ttransitionsEnabled: true,\n\tcomplete: void 0,\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\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 noop = function () {};\n\nvar exportedShims;\n\nif ( !win ) {\n\texportedShims = null;\n} else {\n\texportedShims = {};\n\n\t// Shims for older browsers\n\n\tif ( !Date.now ) {\n\t\tDate.now = function () { return +new Date(); };\n\t}\n\n\tif ( !String.prototype.trim ) {\n\t\tString.prototype.trim = function () {\n\t\t\treturn this.replace(/^\\s+/, '').replace(/\\s+$/, '');\n\t\t};\n\t}\n\n\t// Polyfill for Object.create\n\tif ( !Object.create ) {\n\t\tObject.create = (function () {\n\t\t\tvar Temp = function () {};\n\t\t\treturn function ( prototype, properties ) {\n\t\t\t\tif ( typeof prototype !== 'object' ) {\n\t\t\t\t\tthrow new TypeError( 'Prototype must be an object' );\n\t\t\t\t}\n\t\t\t\tTemp.prototype = prototype;\n\t\t\t\tvar result = new Temp();\n\t\t\t\tdefineProperties( result, properties );\n\t\t\t\tTemp.prototype = null;\n\t\t\t\treturn result;\n\t\t\t};\n\t\t})();\n\t}\n\n\t// Polyfill Object.defineProperty\n\tif ( !Object.defineProperty ) {\n\t\tObject.defineProperty = defineProperty;\n\t}\n\n\tif ( !Object.freeze ) {\n\t\tObject.freeze = function () { 'LOL'; };\n\t}\n\n\t// Polyfill for Object.keys\n\t// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys\n\tif ( !Object.keys ) {\n\t\tObject.keys = (function () {\n\t\t\tvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\t\t\tvar hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString');\n\t\t\tvar dontEnums = [\n\t\t\t\t'toString',\n\t\t\t\t'toLocaleString',\n\t\t\t\t'valueOf',\n\t\t\t\t'hasOwnProperty',\n\t\t\t\t'isPrototypeOf',\n\t\t\t\t'propertyIsEnumerable',\n\t\t\t\t'constructor'\n\t\t\t];\n\t\t\tvar dontEnumsLength = dontEnums.length;\n\n\t\t\treturn function ( obj ) {\n\t\t\t\tif ( typeof obj !== 'object' && typeof obj !== 'function' || obj === null ) {\n\t\t\t\t\tthrow new TypeError( 'Object.keys called on non-object' );\n\t\t\t\t}\n\n\t\t\t\tvar result = [];\n\n\t\t\t\tfor ( var prop in obj ) {\n\t\t\t\t\tif ( hasOwnProperty.call( obj, prop ) ){\n\t\t\t\t\t\tresult.push( prop );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( hasDontEnumBug ) {\n\t\t\t\t\tfor ( var i=0; i < dontEnumsLength; i++ ) {\n\t\t\t\t\t\tif ( hasOwnProperty.call( obj, dontEnums[i] ) ){\n\t\t\t\t\t\t\tresult.push( dontEnums[i] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t};\n\t\t}());\n\t}\n\n\t// TODO: use defineProperty to make these non-enumerable\n\n\t// Array extras\n\tif ( !Array.prototype.indexOf ) {\n\t\tArray.prototype.indexOf = function ( needle, i ) {\n\t\t\tvar this$1 = this;\n\n\t\t\tvar len;\n\n\t\t\tif ( i === undefined ) {\n\t\t\t\ti = 0;\n\t\t\t}\n\n\t\t\tif ( i < 0 ) {\n\t\t\t\ti+= this.length;\n\t\t\t}\n\n\t\t\tif ( i < 0 ) {\n\t\t\t\ti = 0;\n\t\t\t}\n\n\t\t\tfor ( len = this.length; i 1 ) {\n\t\t\t\tvalue = opt_initialValue;\n\t\t\t\tvalueIsSet = true;\n\t\t\t}\n\n\t\t\tfor ( i = 0; i < len; i += 1) {\n\t\t\t\tif ( this$1.hasOwnProperty( i ) ) {\n\t\t\t\t\tif ( valueIsSet ) {\n\t\t\t\t\t\tvalue = callback(value, this$1[i], i, this$1);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalue = this$1[i];\n\t\t\t\t\tvalueIsSet = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( !valueIsSet ) {\n\t\t\t\tthrow new TypeError( 'Reduce of empty array with no initial value' );\n\t\t\t}\n\n\t\t\treturn value;\n\t\t};\n\t}\n\n\tif ( !Array.prototype.filter ) {\n\t\tArray.prototype.filter = function ( filter, context ) {\n\t\t\tvar this$1 = this;\n\n\t\t\tvar i, len;\n\t\t\tvar filtered = [];\n\n\t\t\tfor ( i=0, len=this.length; i>> 0;\n\n\t\t\tif ( typeof iterator !== 'function' ) {\n\t\t\t\tthrow new TypeError();\n\t\t\t}\n\n\t\t\tfor ( i = 0; i < len; i += 1 ) {\n\t\t\t\tif ( i in t && !iterator.call( context, t[i], i, t) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\t}\n\n\tif ( typeof Function.prototype.bind !== 'function' ) {\n\t\tFunction.prototype.bind = function ( context ) {\n\t\t\tvar slice = [].slice;\n\n\t\t\tif ( typeof this !== 'function' ) {\n\t\t\t\tthrow new TypeError( 'Function.prototype.bind called on non-function' );\n\t\t\t}\n\n\t\t\tvar args = slice.call( arguments, 1 );\n\t\t\tvar fn = this;\n\t\t\tvar Empty = function () {};\n\n\t\t\tvar bound = function () {\n\t\t\t\tvar ctx = this instanceof Empty && context ? this : context;\n\t\t\t\treturn fn.apply( ctx, args.concat( slice.call( arguments ) ) );\n\t\t\t};\n\n\t\t\tEmpty.prototype = this.prototype;\n\t\t\tbound.prototype = new Empty();\n\n\t\t\treturn bound;\n\t\t};\n\t}\n\n\t// https://gist.github.com/Rich-Harris/6010282 via https://gist.github.com/jonathantneal/2869388\n\t// addEventListener polyfill IE6+\n\tif ( !win.addEventListener ) {\n\t\t((function(win$$1, doc$$1) {\n\t\t\t// because sometimes inquiring minds want to know\n\t\t\twin$$1.appearsToBeIELessEqual8 = true;\n\n\t\t\tvar Event = function ( e, element ) {\n\t\t\t\tvar instance = this;\n\n\t\t\t\tfor ( var property in e ) {\n\t\t\t\t\tinstance[ property ] = e[ property ];\n\t\t\t\t}\n\n\t\t\t\tinstance.currentTarget = element;\n\t\t\t\tinstance.target = e.srcElement || element;\n\t\t\t\tinstance.timeStamp = +new Date();\n\n\t\t\t\tinstance.preventDefault = function () {\n\t\t\t\t\te.returnValue = false;\n\t\t\t\t};\n\n\t\t\t\tinstance.stopPropagation = function () {\n\t\t\t\t\te.cancelBubble = true;\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tvar addEventListener = function ( type, listener ) {\n\t\t\t\tvar element = this;\n\t\t\t\tvar listeners = element.listeners || ( element.listeners = [] );\n\t\t\t\tvar i = listeners.length;\n\n\t\t\t\tlisteners[i] = [ listener, function (e) {\n\t\t\t\t\tlistener.call( element, new Event( e, element ) );\n\t\t\t\t}];\n\n\t\t\t\telement.attachEvent( 'on' + type, listeners[i][1] );\n\t\t\t};\n\n\t\t\tvar removeEventListener = function ( type, listener ) {\n\t\t\t\tvar element = this;\n\n\t\t\t\tif ( !element.listeners ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar listeners = element.listeners;\n\t\t\t\tvar i = listeners.length;\n\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tif (listeners[i][0] === listener) {\n\t\t\t\t\t\telement.detachEvent( 'on' + type, listeners[i][1] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twin$$1.addEventListener = doc$$1.addEventListener = addEventListener;\n\t\t\twin$$1.removeEventListener = doc$$1.removeEventListener = removeEventListener;\n\n\t\t\tif ( 'Element' in win$$1 ) {\n\t\t\t\twin$$1.Element.prototype.addEventListener = addEventListener;\n\t\t\t\twin$$1.Element.prototype.removeEventListener = removeEventListener;\n\t\t\t} else {\n\t\t\t\t// First, intercept any calls to document.createElement - this is necessary\n\t\t\t\t// because the CSS hack (see below) doesn't come into play until after a\n\t\t\t\t// node is added to the DOM, which is too late for a lot of Ractive setup work\n\t\t\t\tvar origCreateElement = doc$$1.createElement;\n\n\t\t\t\tdoc$$1.createElement = function ( tagName ) {\n\t\t\t\t\tvar el = origCreateElement( tagName );\n\t\t\t\t\tel.addEventListener = addEventListener;\n\t\t\t\t\tel.removeEventListener = removeEventListener;\n\t\t\t\t\treturn el;\n\t\t\t\t};\n\n\t\t\t\t// Then, mop up any additional elements that weren't created via\n\t\t\t\t// document.createElement (i.e. with innerHTML).\n\t\t\t\tvar head = doc$$1.getElementsByTagName('head')[0];\n\t\t\t\tvar style = doc$$1.createElement('style');\n\n\t\t\t\thead.insertBefore( style, head.firstChild );\n\n\t\t\t\t//style.styleSheet.cssText = '*{-ms-event-prototype:expression(!this.addEventListener&&(this.addEventListener=addEventListener)&&(this.removeEventListener=removeEventListener))}';\n\t\t\t}\n\t\t})( win, doc ));\n\t}\n\n\t// The getComputedStyle polyfill interacts badly with jQuery, so we don't attach\n\t// it to window. Instead, we export it for other modules to use as needed\n\n\t// https://github.com/jonathantneal/Polyfills-for-IE8/blob/master/getComputedStyle.js\n\tif ( !win.getComputedStyle ) {\n\t\texportedShims.getComputedStyle = (function () {\n\t\t\tvar borderSizes = {};\n\n\t\t\tfunction getPixelSize ( element, style, property, fontSize ) {\n\t\t\t\tvar sizeWithSuffix = style[property];\n\t\t\t\tvar size = parseFloat(sizeWithSuffix);\n\t\t\t\tvar suffix = sizeWithSuffix.split(/\\d/)[0];\n\n\t\t\t\tif ( isNaN( size ) ) {\n\t\t\t\t\tif ( /^thin|medium|thick$/.test( sizeWithSuffix ) ) {\n\t\t\t\t\t\tsize = getBorderPixelSize( sizeWithSuffix );\n\t\t\t\t\t\tsuffix = '';\n\t\t\t\t\t}\n\n\t\t\t\t\telse {\n\t\t\t\t\t\t// TODO...\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfontSize = fontSize != null ? fontSize : /%|em/.test(suffix) && element.parentElement ? getPixelSize(element.parentElement, element.parentElement.currentStyle, 'fontSize', null) : 16;\n\t\t\t\tvar rootSize = property == 'fontSize' ? fontSize : /width/i.test(property) ? element.clientWidth : element.clientHeight;\n\n\t\t\t\treturn (suffix == 'em') ? size * fontSize : (suffix == 'in') ? size * 96 : (suffix == 'pt') ? size * 96 / 72 : (suffix == '%') ? size / 100 * rootSize : size;\n\t\t\t}\n\n\t\t\tfunction getBorderPixelSize ( size ) {\n\t\t\t\tvar div, bcr;\n\n\t\t\t\t// `thin`, `medium` and `thick` vary between browsers. (Don't ever use them.)\n\t\t\t\tif ( !borderSizes[ size ] ) {\n\t\t\t\t\tdiv = doc.createElement( 'div' );\n\t\t\t\t\tdiv.style.display = 'block';\n\t\t\t\t\tdiv.style.position = 'fixed';\n\t\t\t\t\tdiv.style.width = div.style.height = '0';\n\t\t\t\t\tdiv.style.borderRight = size + ' solid black';\n\n\t\t\t\t\tdoc.getElementsByTagName( 'body' )[0].appendChild( div );\n\t\t\t\t\tbcr = div.getBoundingClientRect();\n\n\t\t\t\t\tborderSizes[ size ] = bcr.right - bcr.left;\n\t\t\t\t}\n\n\t\t\t\treturn borderSizes[ size ];\n\t\t\t}\n\n\t\t\tfunction setShortStyleProperty(style, property) {\n\t\t\t\tvar borderSuffix = property == 'border' ? 'Width' : '';\n\t\t\t\tvar t = property + \"Top\" + borderSuffix;\n\t\t\t\tvar r = property + \"Right\" + borderSuffix;\n\t\t\t\tvar b = property + \"Bottom\" + borderSuffix;\n\t\t\t\tvar l = property + \"Left\" + borderSuffix;\n\n\t\t\t\tstyle[property] = (style[t] == style[r] == style[b] == style[l] ? [style[t]]\n\t\t\t\t: style[t] == style[b] && style[l] == style[r] ? [style[t], style[r]]\n\t\t\t\t: style[l] == style[r] ? [style[t], style[r], style[b]]\n\t\t\t\t: [style[t], style[r], style[b], style[l]]).join(' ');\n\t\t\t}\n\n\t\t\tvar normalProps = {\n\t\t\t\tfontWeight: 400,\n\t\t\t\tlineHeight: 1.2, // actually varies depending on font-family, but is generally close enough...\n\t\t\t\tletterSpacing: 0\n\t\t\t};\n\n\t\t\tfunction CSSStyleDeclaration(element) {\n\t\t\t\tvar currentStyle = element.currentStyle;\n\t\t\t\tvar style = this;\n\t\t\t\tvar fontSize = getPixelSize(element, currentStyle, 'fontSize', null);\n\n\t\t\t\t// TODO tidy this up, test it, send PR to jonathantneal!\n\t\t\t\tfor ( var property in currentStyle ) {\n\t\t\t\t\tif ( currentStyle[property] === 'normal' && normalProps.hasOwnProperty( property ) ) {\n\t\t\t\t\t\tstyle[ property ] = normalProps[ property ];\n\t\t\t\t\t} else if ( /width|height|margin.|padding.|border.+W/.test(property) ) {\n\t\t\t\t\t\tif ( currentStyle[ property ] === 'auto' ) {\n\t\t\t\t\t\t\tif ( /^width|height/.test( property ) ) {\n\t\t\t\t\t\t\t\t// just use clientWidth/clientHeight...\n\t\t\t\t\t\t\t\tstyle[ property ] = ( property === 'width' ? element.clientWidth : element.clientHeight ) + 'px';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\telse if ( /(?:padding)?Top|Bottom$/.test( property ) ) {\n\t\t\t\t\t\t\t\tstyle[ property ] = '0px';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tstyle[ property ] = getPixelSize(element, currentStyle, property, fontSize) + 'px';\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (property === 'styleFloat') {\n\t\t\t\t\t\tstyle.float = currentStyle[property];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstyle[property] = currentStyle[property];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsetShortStyleProperty(style, 'margin');\n\t\t\t\tsetShortStyleProperty(style, 'padding');\n\t\t\t\tsetShortStyleProperty(style, 'border');\n\n\t\t\t\tstyle.fontSize = fontSize + 'px';\n\n\t\t\t\treturn style;\n\t\t\t}\n\n\t\t\tCSSStyleDeclaration.prototype = {\n\t\t\t\tconstructor: CSSStyleDeclaration,\n\t\t\t\tgetPropertyPriority: noop,\n\t\t\t\tgetPropertyValue: function getPropertyValue ( prop ) {\n\t\t\t\t\treturn this[prop] || '';\n\t\t\t\t},\n\t\t\t\titem: noop,\n\t\t\t\tremoveProperty: noop,\n\t\t\t\tsetProperty: noop,\n\t\t\t\tgetPropertyCSSValue: noop\n\t\t\t};\n\n\t\t\tfunction getComputedStyle(element) {\n\t\t\t\treturn new CSSStyleDeclaration(element);\n\t\t\t}\n\n\t\t\treturn getComputedStyle;\n\t\t}());\n\t}\n}\n\nvar legacy = exportedShims;\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 camel = /(-.)/g;\nfunction camelize ( string ) {\n\treturn string.replace( camel, function (s) { return s.charAt( 1 ).toUpperCase(); } );\n}\n\nvar decamel = /[A-Z]/g;\nfunction decamelize ( string ) {\n\treturn string.replace( decamel, function (s) { return (\"-\" + (s.toLowerCase())); } );\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\nvar toString$1$1 = Object.prototype.toString;\nvar arrayLikePattern = /^\\[object (?:Array|FileList)\\]$/;\n\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\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-16ab6a28cd037ae65308b32137032525cd096c8a %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-16ab6a28cd037ae65308b32137032525cd096c8a 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= 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 = getWildcardNames( fullName );\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 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\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