Bundled output for commit 285cb5382f [skip ci]
This commit is contained in:
parent
285cb5382f
commit
277f35fb3a
3 changed files with 251 additions and 145 deletions
|
|
@ -18,7 +18,7 @@ mithril.js [](https://ww
|
|||
|
||||
## What is Mithril?
|
||||
|
||||
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.29 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
|
||||
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.71 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
|
||||
|
||||
Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍.
|
||||
|
||||
|
|
|
|||
302
mithril.js
302
mithril.js
|
|
@ -1,7 +1,7 @@
|
|||
;(function() {
|
||||
"use strict"
|
||||
function Vnode(tag, key, attrs0, children, text, dom) {
|
||||
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
|
||||
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}
|
||||
}
|
||||
Vnode.normalize = function(node) {
|
||||
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
|
||||
|
|
@ -589,38 +589,47 @@ var coreRenderer = function($window) {
|
|||
// are visited in the fourth part of the diff and in the `removeNodes` loop.
|
||||
// ## Diffing
|
||||
//
|
||||
// If one list is keyed and the other is unkeyed, the old is removed, and the new one is
|
||||
// inserted (since the keys are guaranteed to differ).
|
||||
// Reading https://github.com/localvoid/ivi/blob/ddc09d06abaef45248e6133f7040d00d3c6be853/packages/ivi/src/vdom/implementation.ts#L617-L837
|
||||
// may be good for context on longest increasing subsequence-based logic for moving nodes.
|
||||
//
|
||||
// Then comes the unkeyed diff algo, and at last0, the keyed diff algorithm that is split
|
||||
// in four parts (simplifying a bit).
|
||||
// In order to diff keyed lists, one has to
|
||||
//
|
||||
// The first part goes through both lists top-down as long as the nodes at each level have
|
||||
// the same key2.
|
||||
// 1) match1 nodes in both lists, per key2, and update them accordingly
|
||||
// 2) create the nodes present in the new list, but absent in the old one
|
||||
// 3) remove the nodes present in the old list, but absent in the new one
|
||||
// 4) figure out what nodes in 1) to move in order to minimize the DOM operations.
|
||||
//
|
||||
// The second part deals with lists reversals, and traverses one list top-down and the other
|
||||
// bottom-up (as long as the keys match1).
|
||||
// To achieve 1) one can create a dictionary of keys => index0 (for the old list), then1 iterate
|
||||
// over the new list and for each new vnode, find the corresponding vnode in the old list using
|
||||
// the map.
|
||||
// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new
|
||||
// and must be created.
|
||||
// For the removals, we actually remove the nodes that have been updated from the old list.
|
||||
// The nodes that remain in that list after 1) and 2) have been performed can be safely removed.
|
||||
// The fourth step is a bit more complex and relies on the longest increasing subsequence (LIS)
|
||||
// algorithm.
|
||||
//
|
||||
// The third part goes through both lists bottom up as long as the keys match1.
|
||||
// the longest increasing subsequence is the list of nodes that can remain in place. Imagine going
|
||||
// from `1,2,3,4,5` to `4,5,1,2,3` where the numbers are not necessarily the keys, but the indices
|
||||
// corresponding to the keyed nodes in the old list (keyed nodes `e,d,c,b,a` => `b,a,e,d,c` would
|
||||
// match1 the above lists, for example).
|
||||
//
|
||||
// The first and third sections allow us to deal efficiently with situations where one or
|
||||
// more contiguous nodes were either inserted into, removed from or re-ordered in an otherwise
|
||||
// sorted list. They may reduce the number of nodes to be processed in the fourth section.
|
||||
// In there are two increasing subsequences: `4,5` and `1,2,3`, the latter being the longest. We
|
||||
// can update those nodes without moving them, and only call `insertNode` on `4` and `5`.
|
||||
//
|
||||
// The fourth section does keyed diff for the situations not covered by the other three. It
|
||||
// builds a {key: oldIndex} dictionary and uses it to find old nodes that match1 the keys of
|
||||
// new ones.
|
||||
// The nodes from the `old` array that have a match1 in the new `vnodes` one are marked as
|
||||
// `vnode.skip: true`.
|
||||
// @localvoid adapted the algo to also support node deletions and insertions (the `lis` is actually
|
||||
// the longest increasing subsequence *of old nodes still present in the new list*).
|
||||
//
|
||||
// If there are still nodes in the new `vnodes` array that haven't been matched to old ones,
|
||||
// they are created.
|
||||
// The range of old nodes that wasn't covered by the first three sections is passed to
|
||||
// `removeNodes()`. Those nodes are removed unless marked as `.skip: true`.
|
||||
// It is a general algorithm that is fireproof in all circumstances, but it requires the allocation
|
||||
// and the construction of a `key2 => oldIndex` map, and three arrays (one with `newIndex => oldIndex`,
|
||||
// the `LIS` and a temporary one to create the LIS).
|
||||
//
|
||||
// So we cheat where we can: if the tails of the lists are identical, they are guaranteed to be part of
|
||||
// the LIS and can be updated without moving them.
|
||||
//
|
||||
// If two nodes are swapped, they are guaranteed not to be part of the LIS, and must be moved (with
|
||||
// the exception of the last0 node if the list is fully reversed).
|
||||
//
|
||||
// It should be noted that the description of the four sections above is not perfect, because those
|
||||
// parts are actually implemented as only two loops, one for the first two parts, and one for
|
||||
// the other two. I'm1 not sure it wins us anything except maybe a few bytes of file size.
|
||||
// ## Finding the next0 sibling.
|
||||
//
|
||||
// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.
|
||||
|
|
@ -645,11 +654,10 @@ var coreRenderer = function($window) {
|
|||
// three of the diff algo.
|
||||
function updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {
|
||||
if (old === vnodes || old == null && vnodes == null) return
|
||||
else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)
|
||||
else if (vnodes == null) removeNodes(old, 0, old.length)
|
||||
else if (old == null || old.length === 0) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)
|
||||
else if (vnodes == null || vnodes.length === 0) removeNodes(old, 0, old.length)
|
||||
else {
|
||||
// default to keyed because, when either list is full of null nodes, it has fewer branches
|
||||
var start = 0, oldStart = 0, isOldKeyed = true, isKeyed = true
|
||||
var start = 0, oldStart = 0, isOldKeyed = null, isKeyed = null
|
||||
for (; oldStart < old.length; oldStart++) {
|
||||
if (old[oldStart] != null) {
|
||||
isOldKeyed = old[oldStart].key != null
|
||||
|
|
@ -662,12 +670,11 @@ var coreRenderer = function($window) {
|
|||
break
|
||||
}
|
||||
}
|
||||
if (isKeyed === null && isOldKeyed == null) return // both lists are full of nulls
|
||||
if (isOldKeyed !== isKeyed) {
|
||||
removeNodes(old, oldStart, old.length)
|
||||
createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)
|
||||
return
|
||||
}
|
||||
if (!isKeyed) {
|
||||
} else if (!isKeyed) {
|
||||
// Don't index0 past the end of either list (causes deopts).
|
||||
var commonLength = old.length < vnodes.length ? old.length : vnodes.length
|
||||
// Rewind if necessary to the first non-null index0 on either side.
|
||||
|
|
@ -684,71 +691,122 @@ var coreRenderer = function($window) {
|
|||
}
|
||||
if (old.length > commonLength) removeNodes(old, start, old.length)
|
||||
if (vnodes.length > commonLength) createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)
|
||||
return
|
||||
}
|
||||
// keyed diff
|
||||
var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
// both top-down
|
||||
o = old[oldStart]
|
||||
v = vnodes[start]
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) start++
|
||||
else if (o.key === v.key) {
|
||||
oldStart++, start++
|
||||
if (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)
|
||||
} else {
|
||||
// reversal: old top-down, new bottom-up
|
||||
v = vnodes[end]
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) end--
|
||||
else if (o.key === v.key) {
|
||||
oldStart++
|
||||
if (start < end--) insertNode(parent, toFragment(o), nextSibling)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
} else {
|
||||
// keyed diff
|
||||
var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v, oe, ve, topSibling
|
||||
// bottom-up
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
oe = old[oldEnd]
|
||||
ve = vnodes[end]
|
||||
if (oe == null) oldEnd--
|
||||
else if (ve == null) end--
|
||||
else if (oe.key === ve.key) {
|
||||
if (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)
|
||||
if (ve.dom != null) nextSibling = ve.dom
|
||||
oldEnd--, end--
|
||||
} else {
|
||||
break
|
||||
}
|
||||
else break
|
||||
}
|
||||
}
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
// both bottom-up
|
||||
o = old[oldEnd]
|
||||
v = vnodes[end]
|
||||
if (o == null) oldEnd--
|
||||
else if (v == null) end--
|
||||
else if (o.key === v.key) {
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
oldEnd--, end--
|
||||
} else {
|
||||
// old map-based, new bottom-up
|
||||
if (map == null) {
|
||||
// the last0 node can be left out of the map because it will be caught by the
|
||||
// bottom-up part of the diff loop. If we were to refactor this to use distinct
|
||||
// loops, we'd have to pass `oldEnd + 1` (or change `start < end` to `<=` in getKeyMap).
|
||||
map = getKeyMap(old, oldStart, oldEnd)
|
||||
// top-down
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
o = old[oldStart]
|
||||
v = vnodes[start]
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) start++
|
||||
else if (o.key === v.key) {
|
||||
oldStart++, start++
|
||||
if (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
if (v != null) {
|
||||
var oldIndex = map[v.key]
|
||||
if (oldIndex == null) {
|
||||
createNode(parent, v, hooks, ns, nextSibling)
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
} else {
|
||||
o = old[oldIndex]
|
||||
insertNode(parent, toFragment(o), nextSibling)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
o.skip = true
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
}
|
||||
// swaps and list reversals
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) start++
|
||||
else if (oe == null) oldEnd--
|
||||
else if (ve == null) end--
|
||||
else if (start === end) break
|
||||
else {
|
||||
if (o.key !== ve.key || oe.key !== v.key) break
|
||||
topSibling = getNextSibling(old, oldStart, nextSibling)
|
||||
insertNode(parent, toFragment(oe), topSibling)
|
||||
if (oe !== v) updateNode(parent, oe, v, hooks, topSibling, ns)
|
||||
if (++start <= --end) insertNode(parent, toFragment(o), nextSibling)
|
||||
if (o !== ve) updateNode(parent, o, ve, hooks, nextSibling, ns)
|
||||
if (ve.dom != null) nextSibling = ve.dom
|
||||
oldStart++; oldEnd--
|
||||
}
|
||||
oe = old[oldEnd]
|
||||
ve = vnodes[end]
|
||||
o = old[oldStart]
|
||||
v = vnodes[start]
|
||||
}
|
||||
// bottom up once again
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
if (oe == null) oldEnd--
|
||||
else if (ve == null) end--
|
||||
else if (oe.key === ve.key) {
|
||||
if (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)
|
||||
if (ve.dom != null) nextSibling = ve.dom
|
||||
oldEnd--, end--
|
||||
} else {
|
||||
break
|
||||
}
|
||||
oe = old[oldEnd]
|
||||
ve = vnodes[end]
|
||||
}
|
||||
if (start > end) removeNodes(old, oldStart, oldEnd + 1)
|
||||
else if (oldStart > oldEnd) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)
|
||||
else {
|
||||
// inspired by ivi https://github.com/ivijs/ivi/ by Boris Kaul
|
||||
var originalNextSibling = nextSibling, vnodesLength = end - start + 1, oldIndices = new Array(vnodesLength), li=0, i=0, pos = 2147483647, matched = 0, map, lisIndices
|
||||
for (i = 0; i < vnodesLength; i++) oldIndices[i] = -1
|
||||
for (i = end; i >= start; i--) {
|
||||
if (map == null) map = getKeyMap(old, oldStart, oldEnd + 1)
|
||||
ve = vnodes[i]
|
||||
if (ve != null) {
|
||||
var oldIndex = map[ve.key]
|
||||
if (oldIndex != null) {
|
||||
pos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered
|
||||
oldIndices[i-start] = oldIndex
|
||||
oe = old[oldIndex]
|
||||
old[oldIndex] = null
|
||||
if (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)
|
||||
if (ve.dom != null) nextSibling = ve.dom
|
||||
matched++
|
||||
}
|
||||
}
|
||||
}
|
||||
nextSibling = originalNextSibling
|
||||
if (matched !== oldEnd - oldStart + 1) removeNodes(old, oldStart, oldEnd + 1)
|
||||
if (matched === 0) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)
|
||||
else {
|
||||
if (pos === -1) {
|
||||
// the indices of the indices of the items that are part of the
|
||||
// longest increasing subsequence in the oldIndices list
|
||||
lisIndices = makeLisIndices(oldIndices)
|
||||
li = lisIndices.length - 1
|
||||
for (i = end; i >= start; i--) {
|
||||
v = vnodes[i]
|
||||
if (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)
|
||||
else {
|
||||
if (lisIndices[li] === i - start) li--
|
||||
else insertNode(parent, toFragment(v), nextSibling)
|
||||
}
|
||||
if (v.dom != null) nextSibling = vnodes[i].dom
|
||||
}
|
||||
} else {
|
||||
for (i = end; i >= start; i--) {
|
||||
v = vnodes[i]
|
||||
if (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)
|
||||
if (v.dom != null) nextSibling = vnodes[i].dom
|
||||
}
|
||||
}
|
||||
}
|
||||
end--
|
||||
}
|
||||
if (end < start) break
|
||||
}
|
||||
// deal with the leftovers.
|
||||
createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)
|
||||
removeNodes(old, oldStart, oldEnd + 1)
|
||||
}
|
||||
}
|
||||
function updateNode(parent, old, vnode, hooks, nextSibling, ns) {
|
||||
|
|
@ -858,6 +916,55 @@ var coreRenderer = function($window) {
|
|||
}
|
||||
return map
|
||||
}
|
||||
// Lifted from ivi https://github.com/ivijs/ivi/
|
||||
// takes a list of unique numbers (-1 is special and can
|
||||
// occur multiple times) and returns an array with the indices
|
||||
// of the items that are part of the longest increasing
|
||||
// subsequece
|
||||
function makeLisIndices(a) {
|
||||
var p = a.slice()
|
||||
var result = []
|
||||
result.push(0)
|
||||
var u
|
||||
var v
|
||||
for (var i = 0, il = a.length; i < il; ++i) {
|
||||
if (a[i] === -1) {
|
||||
continue
|
||||
}
|
||||
var j = result[result.length - 1]
|
||||
if (a[j] < a[i]) {
|
||||
p[i] = j
|
||||
result.push(i)
|
||||
continue
|
||||
}
|
||||
u = 0
|
||||
v = result.length - 1
|
||||
while (u < v) {
|
||||
/*eslint-disable no-bitwise*/
|
||||
var c = ((u + v) / 2) | 0
|
||||
/*eslint-enable no-bitwise*/
|
||||
if (a[result[c]] < a[i]) {
|
||||
u = c + 1
|
||||
}
|
||||
else {
|
||||
v = c
|
||||
}
|
||||
}
|
||||
if (a[i] < a[result[u]]) {
|
||||
if (u > 0) {
|
||||
p[i] = result[u - 1]
|
||||
}
|
||||
result[u] = i
|
||||
}
|
||||
}
|
||||
u = result.length
|
||||
v = result[u - 1]
|
||||
while (u-- > 0) {
|
||||
result[u] = v
|
||||
v = p[v]
|
||||
}
|
||||
return result
|
||||
}
|
||||
function toFragment(vnode) {
|
||||
var count0 = vnode.domSize
|
||||
if (count0 != null || vnode.dom == null) {
|
||||
|
|
@ -893,10 +1000,7 @@ var coreRenderer = function($window) {
|
|||
function removeNodes(vnodes, start, end) {
|
||||
for (var i = start; i < end; i++) {
|
||||
var vnode = vnodes[i]
|
||||
if (vnode != null) {
|
||||
if (vnode.skip) vnode.skip = false
|
||||
else removeNode(vnode)
|
||||
}
|
||||
if (vnode != null) removeNode(vnode)
|
||||
}
|
||||
}
|
||||
function removeNode(vnode) {
|
||||
|
|
@ -1210,12 +1314,12 @@ var parseQueryString = function(string) {
|
|||
var levels = key5.split(/\]\[?|\[/)
|
||||
var cursor = data0
|
||||
if (key5.indexOf("[") > -1) levels.pop()
|
||||
for (var j = 0; j < levels.length; j++) {
|
||||
var level = levels[j], nextLevel = levels[j + 1]
|
||||
for (var j0 = 0; j0 < levels.length; j0++) {
|
||||
var level = levels[j0], nextLevel = levels[j0 + 1]
|
||||
var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10))
|
||||
var isValue = j === levels.length - 1
|
||||
var isValue = j0 === levels.length - 1
|
||||
if (level === "") {
|
||||
var key5 = levels.slice(0, j).join()
|
||||
var key5 = levels.slice(0, j0).join()
|
||||
if (counters[key5] == null) counters[key5] = 0
|
||||
level = counters[key5]++
|
||||
}
|
||||
|
|
@ -1325,7 +1429,7 @@ var coreRouter = function($window) {
|
|||
}
|
||||
var _21 = function($window, redrawService0) {
|
||||
var routeService = coreRouter($window)
|
||||
var identity = function(v) {return v}
|
||||
var identity = function(v0) {return v0}
|
||||
var render1, component, attrs3, currentPath, lastUpdate
|
||||
var route = function(root, defaultRoute, routes) {
|
||||
if (root == null) throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined")
|
||||
|
|
|
|||
92
mithril.min.js
vendored
92
mithril.min.js
vendored
|
|
@ -1,45 +1,47 @@
|
|||
(function(){function x(b,d,e,g,u,l){return{tag:b,key:d,attrs:e,children:g,text:u,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0,skip:!1}}function M(b){for(var d in b)if(C.call(b,d))return!1;return!0}function w(b){if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");var d=arguments[1],e=2;if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length===
|
||||
e+1){var g=arguments[e];Array.isArray(g)||(g=[g])}else for(g=[];e<arguments.length;)g.push(arguments[e++]);if("string"===typeof b){if(!(e=N[b])){for(var u="div",l=[],h={};e=R.exec(b);){var p=e[1],r=e[2];""===p&&""!==r?u=r:"#"===p?h.id=r:"."===p?l.push(r):"["===e[3][0]&&((p=e[6])&&(p=p.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===e[4]?l.push(p):h[e[4]]=""===p?p:p||!0)}0<l.length&&(h.className=l.join(" "));e=N[b]={tag:u,attrs:h}}g=x.normalizeChildren(g);u=!1;var t,y;l=d.className||d["class"];
|
||||
if(!M(e.attrs)&&!M(d)){h={};for(var a in d)C.call(d,a)&&(h[a]=d[a]);d=h}for(a in e.attrs)C.call(e.attrs,a)&&(d[a]=e.attrs[a]);void 0!==l&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=l),null!=e.attrs.className&&(d.className=e.attrs.className+" "+l));for(a in d)if(C.call(d,a)&&"key"!==a){u=!0;break}Array.isArray(g)&&1===g.length&&null!=g[0]&&"#"===g[0].tag?y=g[0].children:t=g;return x(e.tag,d.key,u?d:void 0,t,y)}return x(b,d.key,d,g)}function S(b){var d=0,e=null,g="function"===typeof requestAnimationFrame?
|
||||
requestAnimationFrame:setTimeout;return function(){var u=Date.now()-d;null===e&&(e=g(function(){e=null;b();d=Date.now()},16-u))}}x.normalize=function(b){return Array.isArray(b)?x("[",void 0,void 0,x.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?x("#",void 0,void 0,!1===b?"":b,void 0,void 0):b};x.normalizeChildren=function(b){for(var d=[],e=0;e<b.length;e++)d[e]=x.normalize(b[e]);return d};var R=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,N={},
|
||||
C={}.hasOwnProperty;w.trust=function(b){null==b&&(b="");return x("<",void 0,void 0,b,void 0,void 0)};w.fragment=function(b,d){return x("[",b.key,b,x.normalizeChildren(d),void 0,void 0)};var m=function(b){function d(b,a){return function G(d){var k;try{if(!a||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(k=d.then))t(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",d);for(var e=0;e<b.length;e++)b[e](d);u.length=0;l.length=0;r.state=a;r.retry=
|
||||
function(){G(d)}});else{if(d===g)throw new TypeError("Promise can't be resolved w/ itself");e(k.bind(d))}}catch(T){p(T)}}}function e(b){function a(a){return function(b){0<d++||a(b)}}var d=0,e=a(p);try{b(a(h),e)}catch(G){e(G)}}if(!(this instanceof m))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var g=this,u=[],l=[],h=d(u,!0),p=d(l,!1),r=g._instance={resolvers:u,rejectors:l},t="function"===typeof setImmediate?setImmediate:
|
||||
setTimeout;e(b)};m.prototype.then=function(b,d){function e(b,d,e,h){d.push(function(a){if("function"!==typeof b)e(a);else try{u(b(a))}catch(A){l&&l(A)}});"function"===typeof g.retry&&h===g.state&&g.retry()}var g=this._instance,u,l,h=new m(function(b,d){u=b;l=d});e(b,g.resolvers,u,!0);e(d,g.rejectors,l,!1);return h};m.prototype["catch"]=function(b){return this.then(null,b)};m.prototype["finally"]=function(b){return this.then(function(d){return m.resolve(b()).then(function(){return d})},function(d){return m.resolve(b()).then(function(){return m.reject(d)})})};
|
||||
m.resolve=function(b){return b instanceof m?b:new m(function(d){d(b)})};m.reject=function(b){return new m(function(d,e){e(b)})};m.all=function(b){return new m(function(d,e){var g=b.length,u=0,l=[];if(0===b.length)d([]);else for(var h=0;h<b.length;h++)(function(p){function r(b){u++;l[p]=b;u===g&&d(l)}null==b[p]||"object"!==typeof b[p]&&"function"!==typeof b[p]||"function"!==typeof b[p].then?r(b[p]):b[p].then(r,e)})(h)})};m.race=function(b){return new m(function(d,e){for(var g=0;g<b.length;g++)b[g].then(d,
|
||||
e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=m:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=m.prototype["finally"]),m=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=m:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=m.prototype["finally"]),m=global.Promise);var E=function(b){function d(b,g){if(Array.isArray(g))for(var h=0;h<g.length;h++)d(b+"["+h+"]",g[h]);
|
||||
else if("[object Object]"===Object.prototype.toString.call(g))for(h in g)d(b+"["+h+"]",g[h]);else e.push(encodeURIComponent(b)+(null!=g&&""!==g?"="+encodeURIComponent(g):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var e=[],g;for(g in b)d(g,b[g]);return e.join("&")},U=/^file:\/\//i,K=function(b,d){function e(){function a(){0===--b&&"function"===typeof y&&y()}var b=0;return function D(d){var e=d.then;d.then=function(){b++;var g=e.apply(d,arguments);g.then(a,function(d){a();
|
||||
if(0===b)throw d;});return D(g)};return d}}function g(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function u(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var g=d[e].slice(1);null!=b[g]&&(a=a.replace(d[e],b[g]))}return a}function l(a,b){var d=E(b);if(""!==d){var e=0>a.indexOf("?")?"?":"&";a+=e+d}return a}function h(a){try{return""!==a?JSON.parse(a):null}catch(A){throw Error(a);}}function p(a){return a.responseText}function r(a,b){if("function"===
|
||||
typeof a)if(Array.isArray(b))for(var d=0;d<b.length;d++)b[d]=new a(b[d]);else return new a(b);return b}var t=0,y;return{request:function(a,t){var k=e();a=g(a,t);var A=new d(function(d,e){null==a.method&&(a.method="GET");a.method=a.method.toUpperCase();var g="GET"===a.method||"TRACE"===a.method?!1:"boolean"===typeof a.useBody?a.useBody:!0;"function"!==typeof a.serialize&&(a.serialize="undefined"!==typeof FormData&&a.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==typeof a.deserialize&&
|
||||
(a.deserialize=h);"function"!==typeof a.extract&&(a.extract=p);a.url=u(a.url,a.data);g?a.data=a.serialize(a.data):a.url=l(a.url,a.data);var k=new b.XMLHttpRequest,t=!1,A=k.abort;k.abort=function(){t=!0;A.call(k)};k.open(a.method,a.url,"boolean"===typeof a.async?a.async:!0,"string"===typeof a.user?a.user:void 0,"string"===typeof a.password?a.password:void 0);a.serialize!==JSON.stringify||!g||a.headers&&a.headers.hasOwnProperty("Content-Type")||k.setRequestHeader("Content-Type","application/json; charset=utf-8");
|
||||
a.deserialize!==h||a.headers&&a.headers.hasOwnProperty("Accept")||k.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(k.withCredentials=a.withCredentials);a.timeout&&(k.timeout=a.timeout);for(var y in a.headers)({}).hasOwnProperty.call(a.headers,y)&&k.setRequestHeader(y,a.headers[y]);"function"===typeof a.config&&(k=a.config(k,a)||k);k.onreadystatechange=function(){if(!t&&4===k.readyState)try{var b=a.extract!==p?a.extract(k,a):a.deserialize(a.extract(k,a));if(a.extract!==p||
|
||||
200<=k.status&&300>k.status||304===k.status||U.test(a.url))d(r(a.type,b));else{var g=Error(k.responseText);g.code=k.status;g.response=b;e(g)}}catch(V){e(V)}};g&&null!=a.data?k.send(a.data):k.send()});return!0===a.background?A:k(A)},jsonp:function(a,p){var k=e();a=g(a,p);var h=new d(function(d,e){var g=a.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+t++,k=b.document.createElement("script");b[g]=function(e){k.parentNode.removeChild(k);d(r(a.type,e));delete b[g]};k.onerror=function(){k.parentNode.removeChild(k);
|
||||
e(Error("JSONP request failed"));delete b[g]};null==a.data&&(a.data={});a.url=u(a.url,a.data);a.data[a.callbackKey||"callback"]=g;k.src=l(a.url,a.data);b.document.documentElement.appendChild(k)});return!0===a.background?h:k(h)},setCompletionCallback:function(a){y=a}}}(window,m),Q=function(b){function d(a,c){if(a.state!==c)throw Error("`vnode.state` must not be modified");}function e(a){var c=a.state;try{return this.apply(c,arguments)}finally{d(a,c)}}function g(a,c,f,b,d,e,g){for(;f<b;f++){var n=c[f];
|
||||
null!=n&&u(a,n,d,g,e)}}function u(n,c,f,b,d){var k=c.tag;if("string"===typeof k)switch(c.state={},null!=c.attrs&&I(c.attrs,c,f),k){case "#":c.dom=z.createTextNode(c.children);y(n,c.dom,d);break;case "<":l(n,c,b,d);break;case "[":var r=z.createDocumentFragment();null!=c.children&&(k=c.children,g(r,k,0,k.length,f,null,b));c.dom=r.firstChild;c.domSize=r.childNodes.length;y(n,r,d);break;default:var q=c.tag,h=(k=c.attrs)&&k.is;q=(b=c.attrs&&c.attrs.xmlns||P[c.tag]||b)?h?z.createElementNS(b,q,{is:h}):z.createElementNS(b,
|
||||
q):h?z.createElement(q,{is:h}):z.createElement(q);c.dom=q;if(null!=k)for(r in h=b,k)D(c,r,null,k[r],h);y(n,q,d);null!=c.attrs&&null!=c.attrs.contenteditable?a(c):(null!=c.text&&(""!==c.text?q.textContent=c.text:c.children=[x("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(n=c.children,g(q,n,0,n.length,f,null,b),f=c.attrs,"select"===c.tag&&null!=f&&("value"in f&&D(c,"value",null,f.value,void 0),"selectedIndex"in f&&D(c,"selectedIndex",null,f.selectedIndex,void 0))))}else{a:{if("function"===
|
||||
typeof c.tag.view){c.state=Object.create(c.tag);r=c.state.view;if(null!=r.$$reentrantLock$$)break a;r.$$reentrantLock$$=!0}else{c.state=void 0;r=c.tag;if(null!=r.$$reentrantLock$$)break a;r.$$reentrantLock$$=!0;c.state=null!=c.tag.prototype&&"function"===typeof c.tag.prototype.view?new c.tag(c):c.tag(c)}null!=c.attrs&&I(c.attrs,c,f);I(c.state,c,f);c.instance=x.normalize(e.call(c.state.view,c));if(c.instance===c)throw Error("A view cannot return the vnode it received as argument");r.$$reentrantLock$$=
|
||||
null}null!=c.instance?(u(n,c.instance,f,b,d),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0):c.domSize=0}}function l(a,c,f,b){var n=c.children.match(/^\s*?<(\w+)/im)||[];n=z.createElement(E[n[1]]||"div");"http://www.w3.org/2000/svg"===f?(n.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+c.children+"</svg>",n=n.firstChild):n.innerHTML=c.children;c.dom=n.firstChild;c.domSize=n.childNodes.length;for(c=z.createDocumentFragment();f=n.firstChild;)c.appendChild(f);y(a,c,b)}function h(a,
|
||||
c,b,d,e,h){if(c!==b&&(null!=c||null!=b))if(null==c)g(a,b,0,b.length,d,e,h);else if(null==b)A(c,0,c.length);else{for(var n=0,f=0,q=!0,l=!0;f<c.length;f++)if(null!=c[f]){q=null!=c[f].key;break}for(;n<b.length;n++)if(null!=b[n]){l=null!=b[n].key;break}if(q!==l)A(c,f,c.length),g(a,b,n,b.length,d,e,h);else if(l){l=c.length-1;for(var B=b.length-1,m,v;l>=f&&B>=n;)if(v=c[f],q=b[n],null==v)f++;else if(null==q)n++;else if(v.key===q.key)f++,n++,v!==q&&p(a,v,q,d,t(c,f,e),h);else if(q=b[B],null==v)f++;else if(null==
|
||||
q)B--;else if(v.key===q.key)f++,n<B--&&y(a,r(v),e),v!==q&&p(a,v,q,d,e,h),null!=q.dom&&(e=q.dom);else break;for(;l>=f&&B>=n;){v=c[l];q=b[B];if(null==v)l--;else{if(null!=q)if(v.key===q.key)v!==q&&p(a,v,q,d,e,h),null!=q.dom&&(e=q.dom),l--;else{if(null==m){m=c;v=f;for(var z=l,x={};v<z;v++){var w=m[v];null!=w&&(w=w.key,null!=w&&(x[w]=v))}m=x}null!=q&&(v=m[q.key],null==v?u(a,q,d,h,e):(v=c[v],y(a,r(v),e),v!==q&&p(a,v,q,d,e,h),v.skip=!0),null!=q.dom&&(e=q.dom))}B--}if(B<n)break}g(a,b,n,B+1,d,e,h);A(c,f,l+
|
||||
1)}else{l=c.length<b.length?c.length:b.length;for(n=n<f?n:f;n<l;n++)v=c[n],q=b[n],v===q||null==v&&null==q||(null==v?u(a,q,d,h,t(c,n+1,e)):null==q?k(v):p(a,v,q,d,t(c,n+1,e),h));c.length>l&&A(c,n,c.length);b.length>l&&g(a,b,n,b.length,d,e,h)}}}function p(b,c,f,d,g,t){var n=c.tag;if(n===f.tag){f.state=c.state;f.events=c.events;var q;var A;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(q=e.call(f.attrs.onbeforeupdate,f,c));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&
|
||||
(A=e.call(f.state.onbeforeupdate,f,c));void 0===q&&void 0===A||q||A?q=!1:(f.dom=c.dom,f.domSize=c.domSize,f.instance=c.instance,q=!0);if(!q)if("string"===typeof n)switch(null!=f.attrs&&J(f.attrs,f,d),n){case "#":c.children.toString()!==f.children.toString()&&(c.dom.nodeValue=f.children);f.dom=c.dom;break;case "<":c.children!==f.children?(r(c),l(b,f,t,g)):(f.dom=c.dom,f.domSize=c.domSize);break;case "[":h(b,c.children,f.children,d,g,t);c=0;d=f.children;f.dom=null;if(null!=d){for(var m=0;m<d.length;m++)t=
|
||||
d[m],null!=t&&null!=t.dom&&(null==f.dom&&(f.dom=t.dom),c+=t.domSize||1);1!==c&&(f.domSize=c)}break;default:b=f.dom=c.dom;t=f.attrs&&f.attrs.xmlns||P[f.tag]||t;"textarea"===f.tag&&(null==f.attrs&&(f.attrs={}),null!=f.text&&(f.attrs.value=f.text,f.text=void 0));g=c.attrs;n=f.attrs;q=t;if(null!=n)for(m in n)D(f,m,g&&g[m],n[m],q);if(null!=g)for(m in g)null!=n&&m in n||("className"===m&&(m="class"),"o"!==m[0]||"n"!==m[1]||w(m)?"key"!==m&&f.dom.removeAttribute(m):O(f,m,void 0));null!=f.attrs&&null!=f.attrs.contenteditable?
|
||||
a(f):null!=c.text&&null!=f.text&&""!==f.text?c.text.toString()!==f.text.toString()&&(c.dom.firstChild.nodeValue=f.text):(null!=c.text&&(c.children=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=f.text&&(f.children=[x("#",void 0,void 0,f.text,void 0,void 0)]),h(b,c.children,f.children,d,null,t))}else{f.instance=x.normalize(e.call(f.state.view,f));if(f.instance===f)throw Error("A view cannot return the vnode it received as argument");null!=f.attrs&&J(f.attrs,f,d);J(f.state,f,d);null!=
|
||||
f.instance?(null==c.instance?u(b,f.instance,d,t,g):p(b,c.instance,f.instance,d,g,t),f.dom=f.instance.dom,f.domSize=f.instance.domSize):null!=c.instance?(k(c.instance),f.dom=void 0,f.domSize=0):(f.dom=c.dom,f.domSize=c.domSize)}}else k(c),u(b,f,d,t,g)}function r(a){var c=a.domSize;if(null!=c||null==a.dom){var b=z.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function t(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=
|
||||
a[c].dom)return a[c].dom;return b}function y(a,c,b){null!=b?a.insertBefore(c,b):a.appendChild(c)}function a(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function A(a,c,b){for(;c<b;c++){var n=a[c];null!=n&&(n.skip?n.skip=!1:k(n))}}function k(a){function c(){if(++n===b&&(d(a,g),m(a),a.dom)){var c=a.domSize||1;if(1<c)for(var f=
|
||||
a.dom;--c;){var e=f.nextSibling,k=e.parentNode;null!=k&&k.removeChild(e)}c=a.dom;f=c.parentNode;null!=f&&f.removeChild(c)}}var b=1,n=0,g=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var k=e.call(a.attrs.onbeforeremove,a);null!=k&&"function"===typeof k.then&&(b++,k.then(c,c))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(k=e.call(a.state.onbeforeremove,a),null!=k&&"function"===typeof k.then&&(b++,k.then(c,c)));c()}function m(a){a.attrs&&"function"===typeof a.attrs.onremove&&
|
||||
e.call(a.attrs.onremove,a);if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&m(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&m(b)}}function D(a,c,b,d,e){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return O(a,c,d);if("undefined"===typeof d&&"value"===c&&b!==d)a.dom.value="";else if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===z.activeElement||
|
||||
"option"===a.tag&&a.dom.parentNode===z.activeElement||"object"===typeof d)&&void 0!==d){var f=a.dom;if("xlink:"===c.slice(0,6))f.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&"object"===typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(f.style[g]=d[g]);for(g in a)g in d||(f.style[g]="")}else if(a===d&&(f.style.cssText="",a=null),null==d)f.style.cssText="";else if("string"===typeof d)f.style.cssText=d;else for(g in"string"===typeof a&&
|
||||
(f.style.cssText=""),d)f.style[g]=d[g];else if(c in f&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===g&&a.dom===z.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===z.activeElement)return}else if(null!==b&&a.dom.value===g&&a.dom===z.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===g)return}"input"===
|
||||
a.tag&&"type"===c?f.setAttribute(c,d):f[c]=d}else"boolean"===typeof d?d?f.setAttribute(c,""):f.removeAttribute(c):f.setAttribute("className"===c?"class":c,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function H(){}function O(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&
|
||||
a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&e.call(a.oninit,c);"function"===typeof a.oncreate&&b.push(e.bind(a.oncreate,c))}function J(a,c,b){"function"===typeof a.onupdate&&b.push(e.bind(a.onupdate,c))}var z=b.document;z.createDocumentFragment();var P={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},
|
||||
C,E={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof C&&C.call(a.target,a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=z.activeElement,
|
||||
e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);h(a,a.vnodes,x.normalizeChildren(c),b,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=c;null!=d&&z.activeElement!==d&&d.focus();for(d=0;d<b.length;d++)b[d]()},setEventCallback:function(a){return C=a}}},F=function(b,d){function e(b){b=l.indexOf(b);-1<b&&l.splice(b,2)}function g(){if(h)throw Error("Nested m.redraw.sync() call");h=!0;for(var b=1;b<l.length;b+=2)try{l[b]()}catch(t){"undefined"!==typeof console&&console.error(t)}h=
|
||||
!1}var m=Q(b);m.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:p()});var l=[],h=!1,p=(d||S)(g);p.sync=g;return{subscribe:function(b,d){e(b);l.push(b,d)},unsubscribe:e,redraw:p,render:m.render}}(window);K.setCompletionCallback(F.redraw);w.mount=function(b){return function(d,e){if(null===e)b.render(d,[]),b.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var g=function(){b.render(d,x(e))};b.subscribe(d,
|
||||
g);g()}}}(F);var W=m,L=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},e={},g=0;g<b.length;g++){var m=b[g].split("="),l=decodeURIComponent(m[0]);m=2===m.length?decodeURIComponent(m[1]):"";"true"===m?m=!0:"false"===m&&(m=!1);var h=l.split(/\]\[?|\[/),p=d;-1<l.indexOf("[")&&h.pop();for(var r=0;r<h.length;r++){l=h[r];var t=h[r+1];t=""==t||!isNaN(parseInt(t,10));var y=r===h.length-1;""===l&&(l=h.slice(0,r).join(),null==e[l]&&(e[l]=0),l=e[l]++);null==
|
||||
p[l]&&(p[l]=y?m:t?[]:{});p=p[l]}}return d},X=function(b){function d(d){var e=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(b){return function(){null==h&&(h=l(function(){h=null;b()}))}}function g(b,d,e){var a=b.indexOf("?"),g=b.indexOf("#"),k=-1<a?a:-1<g?g:b.length;if(-1<a){a=L(b.slice(a+1,-1<g?g:b.length));for(var h in a)d[h]=a[h]}if(-1<g)for(h in d=L(b.slice(g+1)),d)e[h]=d[h];return b.slice(0,k)}var m="function"===typeof b.history.pushState,
|
||||
l="function"===typeof setImmediate?setImmediate:setTimeout,h,p={prefix:"#!",getPath:function(){switch(p.prefix.charAt(0)){case "#":return d("hash").slice(p.prefix.length);case "?":return d("search").slice(p.prefix.length)+d("hash");default:return d("pathname").slice(p.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,h){var a={},l={};d=g(d,a,l);if(null!=e){for(var k in e)a[k]=e[k];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return e[d]})}(k=E(a))&&(d+="?"+k);(l=E(l))&&(d+="#"+l);
|
||||
m?(l=h?h.state:null,k=h?h.title:null,b.onpopstate(),h&&h.replace?b.history.replaceState(l,k,p.prefix+d):b.history.pushState(l,k,p.prefix+d)):b.location.href=p.prefix+d},defineRoutes:function(d,h,l){function a(){var a=p.getPath(),e={},m=g(a,e,e),r=b.history.state;if(null!=r)for(var t in r)e[t]=r[t];for(var u in d)if(r=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),r.test(m)){m.replace(r,function(){for(var b=u.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,
|
||||
1,-2),k=0;k<b.length;k++)e[b[k].replace(/:|\./g,"")]=decodeURIComponent(g[k]);h(d[u],e,a,u)});return}l(a,e)}m?b.onpopstate=e(a):"#"===p.prefix.charAt(0)&&(b.onhashchange=a);a()}};return p};w.route=function(b,d){var e=X(b),g=function(a){return a},m,l,h,p,r,t=function(a,b,k){function t(){null!=m&&d.render(a,m(x(l,h.key,h)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var u=function(){t();u=d.redraw};d.subscribe(a,t);var w=function(a){if(a!==b)e.setPath(b,
|
||||
null,{replace:!0});else throw Error("Could not resolve default route "+b);};e.defineRoutes(k,function(a,b,d){var e=r=function(a,k){e===r&&(l=null==k||"function"!==typeof k.view&&"function"!==typeof k?"div":k,h=b,p=d,r=null,m=(a.render||g).bind(a),u())};a.view||"function"===typeof a?e({},a):a.onmatch?W.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},w):e(a,"div")},w)};t.set=function(a,b,d){null!=r&&(d=d||{},d.replace=!0);r=null;e.setPath(a,b,d)};t.get=function(){return p};t.prefix=function(a){e.prefix=
|
||||
a};var w=function(a,b){b.dom.setAttribute("href",e.prefix+b.attrs.href);b.dom.onclick=function(b){b.ctrlKey||b.metaKey||b.shiftKey||2===b.which||(b.preventDefault(),b.redraw=!1,b=this.getAttribute("href"),0===b.indexOf(e.prefix)&&(b=b.slice(e.prefix.length)),t.set(b,void 0,a))}};t.link=function(a){return null==a.tag?w.bind(w,a):w({},a)};t.param=function(a){return"undefined"!==typeof h&&"undefined"!==typeof a?h[a]:h};return t}(window,F);w.withAttr=function(b,d,e){return function(g){d.call(e||this,
|
||||
b in g.currentTarget?g.currentTarget[b]:g.currentTarget.getAttribute(b))}};var Y=Q(window);w.render=Y.render;w.redraw=F.redraw;w.request=K.request;w.jsonp=K.jsonp;w.parseQueryString=L;w.buildQueryString=E;w.version="1.1.3";w.vnode=x;w.PromisePolyfill=m;"undefined"!==typeof module?module.exports=w:window.m=w})();
|
||||
(function(){function z(a,d,e,f,v,l){return{tag:a,key:d,attrs:e,children:f,text:v,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0}}function Q(a){for(var d in a)if(H.call(a,d))return!1;return!0}function w(a){if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");var d=arguments[1],e=2;if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length===
|
||||
e+1){var f=arguments[e];Array.isArray(f)||(f=[f])}else for(f=[];e<arguments.length;)f.push(arguments[e++]);if("string"===typeof a){if(!(e=R[a])){for(var v="div",l=[],h={};e=V.exec(a);){var n=e[1],t=e[2];""===n&&""!==t?v=t:"#"===n?h.id=t:"."===n?l.push(t):"["===e[3][0]&&((n=e[6])&&(n=n.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===e[4]?l.push(n):h[e[4]]=""===n?n:n||!0)}0<l.length&&(h.className=l.join(" "));e=R[a]={tag:v,attrs:h}}f=z.normalizeChildren(f);v=!1;var g,C;l=d.className||d["class"];
|
||||
if(!Q(e.attrs)&&!Q(d)){h={};for(var c in d)H.call(d,c)&&(h[c]=d[c]);d=h}for(c in e.attrs)H.call(e.attrs,c)&&(d[c]=e.attrs[c]);void 0!==l&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=l),null!=e.attrs.className&&(d.className=e.attrs.className+" "+l));for(c in d)if(H.call(d,c)&&"key"!==c){v=!0;break}Array.isArray(f)&&1===f.length&&null!=f[0]&&"#"===f[0].tag?C=f[0].children:g=f;return z(e.tag,d.key,v?d:void 0,g,C)}return z(a,d.key,d,f)}function W(a){var d=0,e=null,f="function"===typeof requestAnimationFrame?
|
||||
requestAnimationFrame:setTimeout;return function(){var v=Date.now()-d;null===e&&(e=f(function(){e=null;a();d=Date.now()},16-v))}}z.normalize=function(a){return Array.isArray(a)?z("[",void 0,void 0,z.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?z("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};z.normalizeChildren=function(a){for(var d=[],e=0;e<a.length;e++)d[e]=z.normalize(a[e]);return d};var V=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,R={},
|
||||
H={}.hasOwnProperty;w.trust=function(a){null==a&&(a="");return z("<",void 0,void 0,a,void 0,void 0)};w.fragment=function(a,d){return z("[",a.key,a,z.normalizeChildren(d),void 0,void 0)};var k=function(a){function d(a,c){return function K(d){var E;try{if(!c||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(E=d.then))g(function(){c||0!==a.length||console.error("Possible unhandled promise rejection:",d);for(var e=0;e<a.length;e++)a[e](d);v.length=0;l.length=0;t.state=c;t.retry=
|
||||
function(){K(d)}});else{if(d===f)throw new TypeError("Promise can't be resolved w/ itself");e(E.bind(d))}}catch(X){n(X)}}}function e(a){function c(c){return function(a){0<d++||c(a)}}var d=0,e=c(n);try{a(c(h),e)}catch(K){e(K)}}if(!(this instanceof k))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var f=this,v=[],l=[],h=d(v,!0),n=d(l,!1),t=f._instance={resolvers:v,rejectors:l},g="function"===typeof setImmediate?setImmediate:
|
||||
setTimeout;e(a)};k.prototype.then=function(a,d){function e(a,d,e,h){d.push(function(c){if("function"!==typeof a)e(c);else try{v(a(c))}catch(D){l&&l(D)}});"function"===typeof f.retry&&h===f.state&&f.retry()}var f=this._instance,v,l,h=new k(function(a,d){v=a;l=d});e(a,f.resolvers,v,!0);e(d,f.rejectors,l,!1);return h};k.prototype["catch"]=function(a){return this.then(null,a)};k.prototype["finally"]=function(a){return this.then(function(d){return k.resolve(a()).then(function(){return d})},function(d){return k.resolve(a()).then(function(){return k.reject(d)})})};
|
||||
k.resolve=function(a){return a instanceof k?a:new k(function(d){d(a)})};k.reject=function(a){return new k(function(d,e){e(a)})};k.all=function(a){return new k(function(d,e){var f=a.length,v=0,l=[];if(0===a.length)d([]);else for(var h=0;h<a.length;h++)(function(n){function t(a){v++;l[n]=a;v===f&&d(l)}null==a[n]||"object"!==typeof a[n]&&"function"!==typeof a[n]||"function"!==typeof a[n].then?t(a[n]):a[n].then(t,e)})(h)})};k.race=function(a){return new k(function(d,e){for(var f=0;f<a.length;f++)a[f].then(d,
|
||||
e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=k:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=k.prototype["finally"]),k=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=k:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=k.prototype["finally"]),k=global.Promise);var I=function(a){function d(a,f){if(Array.isArray(f))for(var h=0;h<f.length;h++)d(a+"["+h+"]",f[h]);
|
||||
else if("[object Object]"===Object.prototype.toString.call(f))for(h in f)d(a+"["+h+"]",f[h]);else e.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var e=[],f;for(f in a)d(f,a[f]);return e.join("&")},Y=/^file:\/\//i,O=function(a,d){function e(){function c(){0===--a&&"function"===typeof C&&C()}var a=0;return function G(d){var e=d.then;d.then=function(){a++;var f=e.apply(d,arguments);f.then(c,function(d){c();
|
||||
if(0===a)throw d;});return G(f)};return d}}function f(c,a){if("string"===typeof c){var d=c;c=a||{};null==c.url&&(c.url=d)}return c}function v(c,a){if(null==a)return c;for(var d=c.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var f=d[e].slice(1);null!=a[f]&&(c=c.replace(d[e],a[f]))}return c}function l(c,a){var d=I(a);if(""!==d){var e=0>c.indexOf("?")?"?":"&";c+=e+d}return c}function h(c){try{return""!==c?JSON.parse(c):null}catch(D){throw Error(c);}}function n(c){return c.responseText}function t(c,a){if("function"===
|
||||
typeof c)if(Array.isArray(a))for(var d=0;d<a.length;d++)a[d]=new c(a[d]);else return new c(a);return a}var g=0,C;return{request:function(c,g){var E=e();c=f(c,g);var D=new d(function(d,e){null==c.method&&(c.method="GET");c.method=c.method.toUpperCase();var f="GET"===c.method||"TRACE"===c.method?!1:"boolean"===typeof c.useBody?c.useBody:!0;"function"!==typeof c.serialize&&(c.serialize="undefined"!==typeof FormData&&c.data instanceof FormData?function(c){return c}:JSON.stringify);"function"!==typeof c.deserialize&&
|
||||
(c.deserialize=h);"function"!==typeof c.extract&&(c.extract=n);c.url=v(c.url,c.data);f?c.data=c.serialize(c.data):c.url=l(c.url,c.data);var g=new a.XMLHttpRequest,E=!1,D=g.abort;g.abort=function(){E=!0;D.call(g)};g.open(c.method,c.url,"boolean"===typeof c.async?c.async:!0,"string"===typeof c.user?c.user:void 0,"string"===typeof c.password?c.password:void 0);c.serialize!==JSON.stringify||!f||c.headers&&c.headers.hasOwnProperty("Content-Type")||g.setRequestHeader("Content-Type","application/json; charset=utf-8");
|
||||
c.deserialize!==h||c.headers&&c.headers.hasOwnProperty("Accept")||g.setRequestHeader("Accept","application/json, text/*");c.withCredentials&&(g.withCredentials=c.withCredentials);c.timeout&&(g.timeout=c.timeout);for(var C in c.headers)({}).hasOwnProperty.call(c.headers,C)&&g.setRequestHeader(C,c.headers[C]);"function"===typeof c.config&&(g=c.config(g,c)||g);g.onreadystatechange=function(){if(!E&&4===g.readyState)try{var a=c.extract!==n?c.extract(g,c):c.deserialize(c.extract(g,c));if(c.extract!==n||
|
||||
200<=g.status&&300>g.status||304===g.status||Y.test(c.url))d(t(c.type,a));else{var f=Error(g.responseText);f.code=g.status;f.response=a;e(f)}}catch(Z){e(Z)}};f&&null!=c.data?g.send(c.data):g.send()});return!0===c.background?D:E(D)},jsonp:function(c,n){var h=e();c=f(c,n);var D=new d(function(d,e){var f=c.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+g++,n=a.document.createElement("script");a[f]=function(e){n.parentNode.removeChild(n);d(t(c.type,e));delete a[f]};n.onerror=function(){n.parentNode.removeChild(n);
|
||||
e(Error("JSONP request failed"));delete a[f]};null==c.data&&(c.data={});c.url=v(c.url,c.data);c.data[c.callbackKey||"callback"]=f;n.src=l(c.url,c.data);a.document.documentElement.appendChild(n)});return!0===c.background?D:h(D)},setCompletionCallback:function(c){C=c}}}(window,k),U=function(a){function d(p,b){if(p.state!==b)throw Error("`vnode.state` must not be modified");}function e(p){var b=p.state;try{return this.apply(b,arguments)}finally{d(p,b)}}function f(p,b,c,a,d,e,f){for(;c<a;c++){var m=b[c];
|
||||
null!=m&&v(p,m,d,f,e)}}function v(p,b,m,a,d){var t=b.tag;if("string"===typeof t)switch(b.state={},null!=b.attrs&&M(b.attrs,b,m),t){case "#":b.dom=A.createTextNode(b.children);C(p,b.dom,d);break;case "<":l(p,b,a,d);break;case "[":var F=A.createDocumentFragment();null!=b.children&&(t=b.children,f(F,t,0,t.length,m,null,a));b.dom=F.firstChild;b.domSize=F.childNodes.length;C(p,F,d);break;default:var g=b.tag,r=(t=b.attrs)&&t.is;g=(a=b.attrs&&b.attrs.xmlns||T[b.tag]||a)?r?A.createElementNS(a,g,{is:r}):A.createElementNS(a,
|
||||
g):r?A.createElement(g,{is:r}):A.createElement(g);b.dom=g;if(null!=t)for(F in r=a,t)G(b,F,null,t[F],r);C(p,g,d);null!=b.attrs&&null!=b.attrs.contenteditable?c(b):(null!=b.text&&(""!==b.text?g.textContent=b.text:b.children=[z("#",void 0,void 0,b.text,void 0,void 0)]),null!=b.children&&(p=b.children,f(g,p,0,p.length,m,null,a),m=b.attrs,"select"===b.tag&&null!=m&&("value"in m&&G(b,"value",null,m.value,void 0),"selectedIndex"in m&&G(b,"selectedIndex",null,m.selectedIndex,void 0))))}else{a:{if("function"===
|
||||
typeof b.tag.view){b.state=Object.create(b.tag);F=b.state.view;if(null!=F.$$reentrantLock$$)break a;F.$$reentrantLock$$=!0}else{b.state=void 0;F=b.tag;if(null!=F.$$reentrantLock$$)break a;F.$$reentrantLock$$=!0;b.state=null!=b.tag.prototype&&"function"===typeof b.tag.prototype.view?new b.tag(b):b.tag(b)}null!=b.attrs&&M(b.attrs,b,m);M(b.state,b,m);b.instance=z.normalize(e.call(b.state.view,b));if(b.instance===b)throw Error("A view cannot return the vnode it received as argument");F.$$reentrantLock$$=
|
||||
null}null!=b.instance?(v(p,b.instance,m,a,d),b.dom=b.instance.dom,b.domSize=null!=b.dom?b.instance.domSize:0):b.domSize=0}}function l(c,b,m,a){var p=b.children.match(/^\s*?<(\w+)/im)||[];p=A.createElement(I[p[1]]||"div");"http://www.w3.org/2000/svg"===m?(p.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+b.children+"</svg>",p=p.firstChild):p.innerHTML=b.children;b.dom=p.firstChild;b.domSize=p.childNodes.length;for(b=A.createDocumentFragment();m=p.firstChild;)b.appendChild(m);C(c,b,a)}function h(p,
|
||||
b,c,a,d,e){if(b!==c&&(null!=b||null!=c))if(null==b||0===b.length)f(p,c,0,c.length,a,d,e);else if(null==c||0===c.length)D(b,0,b.length);else{for(var m=0,r=0,h=null,q=null;r<b.length;r++)if(null!=b[r]){h=null!=b[r].key;break}for(;m<c.length;m++)if(null!=c[m]){q=null!=c[m].key;break}if(null!==q||null!=h)if(h!==q)D(b,r,b.length),f(p,c,m,c.length,a,d,e);else if(q){q=b.length-1;h=c.length-1;for(var l,x,u,k,y,B;q>=r&&h>=m;)if(k=b[q],y=c[h],null==k)q--;else if(null==y)h--;else if(k.key===y.key)k!==y&&n(p,
|
||||
k,y,a,d,e),null!=y.dom&&(d=y.dom),q--,h--;else break;for(;q>=r&&h>=m;)if(x=b[r],u=c[m],null==x)r++;else if(null==u)m++;else if(x.key===u.key)r++,m++,x!==u&&n(p,x,u,a,g(b,r,d),e);else break;for(;q>=r&&h>=m;){if(null==x)r++;else if(null==u)m++;else if(null==k)q--;else if(null==y)h--;else if(m===h)break;else{if(x.key!==y.key||k.key!==u.key)break;B=g(b,r,d);C(p,t(k),B);k!==u&&n(p,k,u,a,B,e);++m<=--h&&C(p,t(x),d);x!==y&&n(p,x,y,a,d,e);null!=y.dom&&(d=y.dom);r++;q--}k=b[q];y=c[h];x=b[r];u=c[m]}for(;q>=
|
||||
r&&h>=m;){if(null==k)q--;else if(null==y)h--;else if(k.key===y.key)k!==y&&n(p,k,y,a,d,e),null!=y.dom&&(d=y.dom),q--,h--;else break;k=b[q];y=c[h]}if(m>h)D(b,r,q+1);else if(r>q)f(p,c,m,h+1,a,d,e);else{u=d;k=h-m+1;x=Array(k);var A=2147483647,z=0;for(B=0;B<k;B++)x[B]=-1;for(B=h;B>=m;B--){if(null==l){l=b;k=r;y=q+1;for(var w={};k<y;k++){var G=l[k];null!=G&&(G=G.key,null!=G&&(w[G]=k))}l=w}y=c[B];null!=y&&(w=l[y.key],null!=w&&(A=w<A?w:-1,x[B-m]=w,k=b[w],b[w]=null,k!==y&&n(p,k,y,a,d,e),null!=y.dom&&(d=y.dom),
|
||||
z++))}d=u;z!==q-r+1&&D(b,r,q+1);if(0===z)f(p,c,m,h+1,a,d,e);else if(-1===A){r=x.slice();b=[];b.push(0);q=0;for(B=x.length;q<B;++q)if(-1!==x[q])if(u=b[b.length-1],x[u]<x[q])r[q]=u,b.push(q);else{u=0;for(A=b.length-1;u<A;)z=(u+A)/2|0,x[b[z]]<x[q]?u=z+1:A=z;x[q]<x[b[u]]&&(0<u&&(r[q]=b[u-1]),b[u]=q)}u=b.length;for(A=b[u-1];0<u--;)b[u]=A,A=r[A];r=b.length-1;for(B=h;B>=m;B--)u=c[B],-1===x[B-m]?v(p,u,a,e,d):b[r]===B-m?r--:C(p,t(u),d),null!=u.dom&&(d=c[B].dom)}else for(B=h;B>=m;B--)u=c[B],-1===x[B-m]&&v(p,
|
||||
u,a,e,d),null!=u.dom&&(d=c[B].dom)}}else{h=b.length<c.length?b.length:c.length;for(m=m<r?m:r;m<h;m++)x=b[m],u=c[m],x===u||null==x&&null==u||(null==x?v(p,u,a,e,g(b,m+1,d)):null==u?E(x):n(p,x,u,a,g(b,m+1,d),e));b.length>h&&D(b,m,b.length);c.length>h&&f(p,c,m,c.length,a,d,e)}}}function n(p,b,a,d,f,g){var m=b.tag;if(m===a.tag){a.state=b.state;a.events=b.events;var r;var k;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&&(r=e.call(a.attrs.onbeforeupdate,a,b));"string"!==typeof a.tag&&"function"===
|
||||
typeof a.state.onbeforeupdate&&(k=e.call(a.state.onbeforeupdate,a,b));void 0===r&&void 0===k||r||k?r=!1:(a.dom=b.dom,a.domSize=b.domSize,a.instance=b.instance,r=!0);if(!r)if("string"===typeof m)switch(null!=a.attrs&&N(a.attrs,a,d),m){case "#":b.children.toString()!==a.children.toString()&&(b.dom.nodeValue=a.children);a.dom=b.dom;break;case "<":b.children!==a.children?(t(b),l(p,a,g,f)):(a.dom=b.dom,a.domSize=b.domSize);break;case "[":h(p,b.children,a.children,d,f,g);b=0;d=a.children;a.dom=null;if(null!=
|
||||
d){for(var q=0;q<d.length;q++)g=d[q],null!=g&&null!=g.dom&&(null==a.dom&&(a.dom=g.dom),b+=g.domSize||1);1!==b&&(a.domSize=b)}break;default:p=a.dom=b.dom;g=a.attrs&&a.attrs.xmlns||T[a.tag]||g;"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));f=b.attrs;m=a.attrs;r=g;if(null!=m)for(q in m)G(a,q,f&&f[q],m[q],r);if(null!=f)for(q in f)null!=m&&q in m||("className"===q&&(q="class"),"o"!==q[0]||"n"!==q[1]||w(q)?"key"!==q&&a.dom.removeAttribute(q):S(a,q,void 0));
|
||||
null!=a.attrs&&null!=a.attrs.contenteditable?c(a):null!=b.text&&null!=a.text&&""!==a.text?b.text.toString()!==a.text.toString()&&(b.dom.firstChild.nodeValue=a.text):(null!=b.text&&(b.children=[z("#",void 0,void 0,b.text,void 0,b.dom.firstChild)]),null!=a.text&&(a.children=[z("#",void 0,void 0,a.text,void 0,void 0)]),h(p,b.children,a.children,d,null,g))}else{a.instance=z.normalize(e.call(a.state.view,a));if(a.instance===a)throw Error("A view cannot return the vnode it received as argument");null!=
|
||||
a.attrs&&N(a.attrs,a,d);N(a.state,a,d);null!=a.instance?(null==b.instance?v(p,a.instance,d,g,f):n(p,b.instance,a.instance,d,f,g),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=b.instance?(E(b.instance),a.dom=void 0,a.domSize=0):(a.dom=b.dom,a.domSize=b.domSize)}}else E(b),v(p,a,d,g,f)}function t(a){var b=a.domSize;if(null!=b||null==a.dom){var c=A.createDocumentFragment();if(0<b){for(a=a.dom;--b;)c.appendChild(a.nextSibling);c.insertBefore(a,c.firstChild)}return c}return a.dom}function g(a,
|
||||
b,c){for(;b<a.length;b++)if(null!=a[b]&&null!=a[b].dom)return a[b].dom;return c}function C(a,b,c){null!=c?a.insertBefore(b,c):a.appendChild(b)}function c(a){var b=a.children;if(null!=b&&1===b.length&&"<"===b[0].tag)b=b[0].children,a.dom.innerHTML!==b&&(a.dom.innerHTML=b);else if(null!=a.text||null!=b&&0!==b.length)throw Error("Child node of a contenteditable must be trusted");}function D(a,b,c){for(;b<c;b++){var d=a[b];null!=d&&E(d)}}function E(a){function b(){if(++p===c&&(d(a,f),k(a),a.dom)){var b=
|
||||
a.domSize||1;if(1<b)for(var e=a.dom;--b;){var g=e.nextSibling,m=g.parentNode;null!=m&&m.removeChild(g)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b)}}var c=1,p=0,f=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var g=e.call(a.attrs.onbeforeremove,a);null!=g&&"function"===typeof g.then&&(c++,g.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(g=e.call(a.state.onbeforeremove,a),null!=g&&"function"===typeof g.then&&(c++,g.then(b,b)));b()}function k(a){a.attrs&&
|
||||
"function"===typeof a.attrs.onremove&&e.call(a.attrs.onremove,a);if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&k(a.instance);else if(a=a.children,Array.isArray(a))for(var b=0;b<a.length;b++){var c=a[b];null!=c&&k(c)}}function G(a,b,c,d,e){if("key"!==b&&"is"!==b&&!w(b)){if("o"===b[0]&&"n"===b[1])return S(a,b,d);if("undefined"===typeof d&&"value"===b&&c!==d)a.dom.value="";else if((c!==d||"value"===b||"checked"===b||"selectedIndex"===b||
|
||||
"selected"===b&&a.dom===A.activeElement||"option"===a.tag&&a.dom.parentNode===A.activeElement||"object"===typeof d)&&void 0!==d){var f=a.dom;if("xlink:"===b.slice(0,6))f.setAttributeNS("http://www.w3.org/1999/xlink",b,d);else if("style"===b)if(a=c,null!=a&&null!=d&&"object"===typeof a&&"object"===typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(f.style[g]=d[g]);for(g in a)g in d||(f.style[g]="")}else if(a===d&&(f.style.cssText="",a=null),null==d)f.style.cssText="";else if("string"===typeof d)f.style.cssText=
|
||||
d;else for(g in"string"===typeof a&&(f.style.cssText=""),d)f.style[g]=d[g];else if(b in f&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===b){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===g&&a.dom===A.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===A.activeElement)return}else if(null!==c&&a.dom.value===g&&a.dom===A.activeElement)return;if("option"===a.tag&&null!=
|
||||
c&&a.dom.value===g)return}"input"===a.tag&&"type"===b?f.setAttribute(b,d):f[b]=d}else"boolean"===typeof d?d?f.setAttribute(b,""):f.removeAttribute(b):f.setAttribute("className"===b?"class":b,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function L(){}function S(a,b,c){null!=a.events?a.events[b]!==c&&(null==c||"function"!==typeof c&&"object"!==typeof c?(null!=a.events[b]&&a.dom.removeEventListener(b.slice(2),a.events,
|
||||
!1),a.events[b]=void 0):(null==a.events[b]&&a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)):null==c||"function"!==typeof c&&"object"!==typeof c||(a.events=new L,a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)}function M(a,b,c){"function"===typeof a.oninit&&e.call(a.oninit,b);"function"===typeof a.oncreate&&c.push(e.bind(a.oncreate,b))}function N(a,b,c){"function"===typeof a.onupdate&&c.push(e.bind(a.onupdate,b))}var A=a.document;A.createDocumentFragment();var T={svg:"http://www.w3.org/2000/svg",
|
||||
math:"http://www.w3.org/1998/Math/MathML"},H,I={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};L.prototype=Object.create(null);L.prototype.handleEvent=function(a){var b=this["on"+a.type];"function"===typeof b?b.call(a.target,a):"function"===typeof b.handleEvent&&b.handleEvent(a);"function"===typeof H&&H.call(a.target,a)};return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");
|
||||
var c=[],d=A.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);h(a,a.vnodes,z.normalizeChildren(b),c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;null!=d&&A.activeElement!==d&&d.focus();for(d=0;d<c.length;d++)c[d]()},setEventCallback:function(a){return H=a}}},J=function(a,d){function e(a){a=l.indexOf(a);-1<a&&l.splice(a,2)}function f(){if(h)throw Error("Nested m.redraw.sync() call");h=!0;for(var a=1;a<l.length;a+=2)try{l[a]()}catch(g){"undefined"!==
|
||||
typeof console&&console.error(g)}h=!1}var k=U(a);k.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:n()});var l=[],h=!1,n=(d||W)(f);n.sync=f;return{subscribe:function(a,d){e(a);l.push(a,d)},unsubscribe:e,redraw:n,render:k.render}}(window);O.setCompletionCallback(J.redraw);w.mount=function(a){return function(d,e){if(null===e)a.render(d,[]),a.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var f=function(){a.render(d,
|
||||
z(e))};a.subscribe(d,f);f()}}}(J);var aa=k,P=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},f=0;f<a.length;f++){var k=a[f].split("="),l=decodeURIComponent(k[0]);k=2===k.length?decodeURIComponent(k[1]):"";"true"===k?k=!0:"false"===k&&(k=!1);var h=l.split(/\]\[?|\[/),n=d;-1<l.indexOf("[")&&h.pop();for(var t=0;t<h.length;t++){l=h[t];var g=h[t+1];g=""==g||!isNaN(parseInt(g,10));var C=t===h.length-1;""===l&&(l=h.slice(0,t).join(),null==e[l]&&
|
||||
(e[l]=0),l=e[l]++);null==n[l]&&(n[l]=C?k:g?[]:{});n=n[l]}}return d},ba=function(a){function d(d){var e=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(a){return function(){null==h&&(h=l(function(){h=null;a()}))}}function f(a,d,e){var c=a.indexOf("?"),f=a.indexOf("#"),g=-1<c?c:-1<f?f:a.length;if(-1<c){c=P(a.slice(c+1,-1<f?f:a.length));for(var h in c)d[h]=c[h]}if(-1<f)for(h in d=P(a.slice(f+1)),d)e[h]=d[h];return a.slice(0,
|
||||
g)}var k="function"===typeof a.history.pushState,l="function"===typeof setImmediate?setImmediate:setTimeout,h,n={prefix:"#!",getPath:function(){switch(n.prefix.charAt(0)){case "#":return d("hash").slice(n.prefix.length);case "?":return d("search").slice(n.prefix.length)+d("hash");default:return d("pathname").slice(n.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,h){var c={},g={};d=f(d,c,g);if(null!=e){for(var l in e)c[l]=e[l];d=d.replace(/:([^\/]+)/g,function(a,d){delete c[d];return e[d]})}(l=
|
||||
I(c))&&(d+="?"+l);(g=I(g))&&(d+="#"+g);k?(g=h?h.state:null,l=h?h.title:null,a.onpopstate(),h&&h.replace?a.history.replaceState(g,l,n.prefix+d):a.history.pushState(g,l,n.prefix+d)):a.location.href=n.prefix+d},defineRoutes:function(d,g,h){function c(){var c=n.getPath(),e={},k=f(c,e,e),l=a.history.state;if(null!=l)for(var t in l)e[t]=l[t];for(var v in d)if(l=new RegExp("^"+v.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(k)){k.replace(l,function(){for(var a=v.match(/:[^\/]+/g)||
|
||||
[],f=[].slice.call(arguments,1,-2),h=0;h<a.length;h++)e[a[h].replace(/:|\./g,"")]=decodeURIComponent(f[h]);g(d[v],e,c,v)});return}h(c,e)}k?a.onpopstate=e(c):"#"===n.prefix.charAt(0)&&(a.onhashchange=c);c()}};return n};w.route=function(a,d){var e=ba(a),f=function(a){return a},k,l,h,n,t,g=function(a,g,v){function c(){null!=k&&d.render(a,k(z(l,h.key,h)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var w=function(){c();w=d.redraw};d.subscribe(a,c);var E=
|
||||
function(a){if(a!==g)e.setPath(g,null,{replace:!0});else throw Error("Could not resolve default route "+g);};e.defineRoutes(v,function(a,c,d){var e=t=function(a,g){e===t&&(l=null==g||"function"!==typeof g.view&&"function"!==typeof g?"div":g,h=c,n=d,t=null,k=(a.render||f).bind(a),w())};a.view||"function"===typeof a?e({},a):a.onmatch?aa.resolve(a.onmatch(c,d)).then(function(c){e(a,c)},E):e(a,"div")},E)};g.set=function(a,d,f){null!=t&&(f=f||{},f.replace=!0);t=null;e.setPath(a,d,f)};g.get=function(){return n};
|
||||
g.prefix=function(a){e.prefix=a};var w=function(a,d){d.dom.setAttribute("href",e.prefix+d.attrs.href);d.dom.onclick=function(c){c.ctrlKey||c.metaKey||c.shiftKey||2===c.which||(c.preventDefault(),c.redraw=!1,c=this.getAttribute("href"),0===c.indexOf(e.prefix)&&(c=c.slice(e.prefix.length)),g.set(c,void 0,a))}};g.link=function(a){return null==a.tag?w.bind(w,a):w({},a)};g.param=function(a){return"undefined"!==typeof h&&"undefined"!==typeof a?h[a]:h};return g}(window,J);w.withAttr=function(a,d,e){return function(f){d.call(e||
|
||||
this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var ca=U(window);w.render=ca.render;w.redraw=J.redraw;w.request=O.request;w.jsonp=O.jsonp;w.parseQueryString=P;w.buildQueryString=I;w.version="1.1.3";w.vnode=z;w.PromisePolyfill=k;"undefined"!==typeof module?module.exports=w:window.m=w})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue