forked from prateekbh/veronica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveronica+compiler.min.js
1 lines (1 loc) · 27.3 KB
/
veronica+compiler.min.js
1
!function(a,b){"use strict";function c(a){var b=da(0),c=a.trim().slice(b.length).match(/^\s*(\S+?)\s*(?:,\s*(\S+))?\s+in\s+(.+)$/);return c?{key:c[1],pos:c[2],val:b+c[3]}:{val:a}}function d(a,b,c){var d={};return d[a.key]=b,a.pos&&(d[a.pos]=c),d}function e(a,b,e){n(a,"each");var f,g=r(a),i=a.outerHTML,j=!!ha[g],k=ha[g]||{tmpl:i},l=a.parentNode,m=document.createComment("riot placeholder"),p=[],q=o(a);l.insertBefore(m,a),e=c(e),b.one("premount",function(){l.stub&&(l=b.root),a.parentNode.removeChild(a)}).on("update",function(){var c=ea(e.val,b);ba(c)||(f=c?JSON.stringify(c):"",c=c?Object.keys(c).map(function(a){return d(e,a,c[a])}):[]);for(var i=document.createDocumentFragment(),n=p.length,o=c.length;n>o;)p[--n].unmount(),p.splice(n,1);for(n=0;o>n;++n){var r=!f&&e.key?d(e,c[n],n):c[n];p[n]?p[n].update(r):((p[n]=new h(k,{parent:b,isLoop:!0,hasImpl:j,root:$.test(g)?l:a.cloneNode(),item:r},a.innerHTML)).mount(),i.appendChild(p[n].root)),p[n]._item=r}l.insertBefore(i,m),q&&(b.tags[g]=p)}).one("updated",function(){var a=Object.keys(b);u(l,function(c){1!=c.nodeType||c.isLoop||c._looped||(c._visited=!1,c._looped=!0,C(c,b,a))})})}function f(a,b,c){u(a,function(a){if(1==a.nodeType){a.isLoop=a.isLoop||a.parentNode&&a.parentNode.isLoop||a.getAttribute("each")?1:0;var d=o(a);d&&!a.isLoop&&c.push(p(d,a,b)),a.isLoop||C(a,b,[])}})}function g(a,b,c){function d(a,b,d){if(b.indexOf(da(0))>=0){var e={dom:a,expr:b};c.push(s(e,d))}}u(a,function(a){var c=a.nodeType;if(3==c&&"STYLE"!=a.parentNode.tagName&&d(a,a.nodeValue),1==c){var f=a.getAttribute("each");return f?(e(a,b,f),!1):(l(a.attributes,function(b){var c=b.name,e=c.split("__")[1];return d(a,b.value,{attr:e||c,bool:e}),e?(n(a,c),!1):void 0}),o(a)?!1:void 0)}})}function h(a,c,d){function e(){var a=x&&u?n:r||n;l(D.attributes,function(b){o[b.name]=ea(b.value,a)}),l(Object.keys(G),function(b){o[b]=ea(G[b],a)})}function h(a){for(var b in z)typeof n[b]!==Y&&(n[b]=a[b])}function i(){n.parent&&u&&l(Object.keys(n.parent),function(a){var b=!~_.indexOf(a)&&~H.indexOf(a);(typeof n[a]===Y||b)&&(b||H.push(a),n[a]=n.parent[a])})}function j(a){if(l(C,function(b){b[a?"mount":"unmount"]()}),r){var b=a?"on":"off";u?r[b]("unmount",n.unmount):r[b]("update",n.update)[b]("unmount",n.unmount)}}var n=S.observable(this),o=B(c.opts)||{},p=fa(a.tmpl),r=c.parent,u=c.isLoop,x=c.hasImpl,z=t(c.item),A=[],C=[],D=c.root,E=a.fn,F=D.tagName.toLowerCase(),G={},H=[];E&&D._tag&&D._tag.unmount(!0),this.isMounted=!1,D.isLoop=u,D._tag=this,this._id=T++,s(this,{parent:r,root:D,opts:o,tags:{}},z),l(D.attributes,function(a){var b=a.value;da(/{.*}/).test(b)&&(G[a.name]=b)}),p.innerHTML&&!/^(select|optgroup|table|tbody|tr|col(?:group)?)$/.test(F)&&(p.innerHTML=y(p.innerHTML,d)),this.update=function(a){a=t(a),i(),a&&typeof z===X&&(h(a),z=a),s(n,a),e(),n.trigger("update",a),k(A,n),n.trigger("updated")},this.mixin=function(){l(arguments,function(a){a=typeof a===W?S.mixin(a):a,l(Object.keys(a),function(b){"init"!=b&&(n[b]=m(a[b])?a[b].bind(n):a[b])}),a.init&&a.init.bind(n)()})},this.mount=function(){if(e(),E&&E.call(n,o),g(p,n,A),j(!0),(a.attrs||x)&&(v(a.attrs,function(a,b){D.setAttribute(a,b)}),g(n.root,n,A)),(!n.parent||u)&&n.update(z),n.trigger("premount"),u&&!x)n.root=D=p.firstChild;else{for(;p.firstChild;)D.appendChild(p.firstChild);D.stub&&(n.root=D=r.root)}!n.parent||n.parent.isMounted?(n.isMounted=!0,n.trigger("mount")):n.parent.one("mount",function(){w(n.root)||(n.parent.isMounted=n.isMounted=!0,n.trigger("mount"))})},this.unmount=function(a){var c,d=D,e=d.parentNode;if(e){if(r)c=q(r),ba(c.tags[F])?l(c.tags[F],function(a,b){a._id==n._id&&c.tags[F].splice(b,1)}):c.tags[F]=b;else for(;d.firstChild;)d.removeChild(d.firstChild);a?e.removeAttribute("riot-tag"):e.removeChild(d)}n.trigger("unmount"),j(),n.off("*"),D._tag=null},f(p,this,C)}function i(b,c,d,e){d[b]=function(b){var f,g=e._item,h=e.parent;if(!g)for(;h&&!g;)g=h._item,h=h.parent;b=b||a.event;try{b.currentTarget=d,b.target||(b.target=b.srcElement),b.which||(b.which=b.charCode||b.keyCode)}catch(i){}b.item=g,c.call(e,b)===!0||/radio|check/.test(d.type)||(b.preventDefault&&b.preventDefault(),b.returnValue=!1),b.preventUpdate||(f=g?q(h):e,f.update())}}function j(a,b,c){a&&(a.insertBefore(c,b),a.removeChild(b))}function k(a,b){l(a,function(a,c){var d=a.dom,e=a.attr,f=ea(a.expr,b),g=a.dom.parentNode;if(a.bool?f=f?e:!1:null==f&&(f=""),g&&"TEXTAREA"==g.tagName&&(f=(""+f).replace(/riot-/g,"")),a.value!==f){if(a.value=f,!e)return void(d.nodeValue=""+f);if(n(d,e),m(f))i(e,f,d,b);else if("if"==e){var h=a.stub,k=function(){j(h.parentNode,h,d)},l=function(){j(d.parentNode,d,h)};f?h&&(k(),d.inStub=!1,w(d)||u(d,function(a){a._tag&&!a._tag.isMounted&&(a._tag.isMounted=!!a._tag.trigger("mount"))})):(h=a.stub=h||document.createTextNode(""),d.parentNode?l():(b.parent||b).one("updated",l),d.inStub=!0)}else if(/^(show|hide)$/.test(e))"hide"==e&&(f=!f),d.style.display=f?"":"none";else if("value"==e)d.value=f;else if(D(e,U)&&e!=V)f&&d.setAttribute(e.slice(U.length),f);else{if(a.bool&&(d[e]=f,!f))return;typeof f!==X&&d.setAttribute(e,f)}}})}function l(a,b){for(var c,d=0,e=(a||[]).length;e>d;d++)c=a[d],null!=c&&b(c,d)===!1&&d--;return a}function m(a){return typeof a===Z||!1}function n(a,b){a.removeAttribute(b)}function o(a){return a.tagName&&ha[a.getAttribute(V)||a.tagName.toLowerCase()]}function p(a,b,c){var d,e=new h(a,{root:b,parent:c},b.innerHTML),f=r(b),g=q(c);return e.parent=g,d=g.tags[f],d?(ba(d)||(g.tags[f]=[d]),~g.tags[f].indexOf(e)||g.tags[f].push(e)):g.tags[f]=e,b.innerHTML="",e}function q(a){for(var b=a;!o(b.root)&&b.parent;)b=b.parent;return b}function r(a){var b=o(a),c=a.getAttribute("name"),d=c&&c.indexOf(da(0))<0?c:b?b.name:a.tagName.toLowerCase();return d}function s(a){for(var b,c=arguments,d=1;d<c.length;++d)if(b=c[d])for(var e in b)a[e]=b[e];return a}function t(a){if(!(a instanceof h||a&&typeof a.trigger==Z))return a;var b={};for(var c in a)~_.indexOf(c)||(b[c]=a[c]);return b}function u(a,b){if(a){if(b(a)===!1)return;for(a=a.firstChild;a;)u(a,b),a=a.nextSibling}}function v(a,b){for(var c,d=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g;c=d.exec(a);)b(c[1].toLowerCase(),c[2]||c[3]||c[4])}function w(a){for(;a;){if(a.inStub)return!0;a=a.parentNode}return!1}function x(a){return document.createElement(a)}function y(a,b){return a.replace(/<(yield)\/?>(<\/\1>)?/gi,b||"")}function z(a,b){return(b||document).querySelectorAll(a)}function A(a,b){return(b||document).querySelector(a)}function B(a){function b(){}return b.prototype=a,new b}function C(a,b,c){if(!a._visited){var d,e=a.getAttribute("id")||a.getAttribute("name");e&&(c.indexOf(e)<0&&(d=b[e],d?ba(d)?d.push(a):b[e]=[d,a]:b[e]=a),a._visited=!0)}}function D(a,b){return a.slice(0,b.length)===b}function E(a){if(!S.render){ca||(ca=x("style"),ca.setAttribute("type","text/css"));var b=document.head||document.getElementsByTagName("head")[0];if(ca.styleSheet?ca.styleSheet.cssText+=a:ca.innerHTML+=a,!ca._rendered)if(ca.styleSheet)document.body.appendChild(ca);else{var c=A("style[type=riot]");c?(c.parentNode.insertBefore(ca,c),c.parentNode.removeChild(c)):b.appendChild(ca)}ca._rendered=!0}}function F(a,b,c){var d=ha[b],e=a._innerHTML=a._innerHTML||a.innerHTML;return a.innerHTML="",d&&a&&(d=new h(d,{root:a,opts:c},e)),d&&d.mount?(d.mount(),ga.push(d),d.on("unmount",function(){ga.splice(ga.indexOf(d),1)})):void 0}function G(a,b,c,d,e){return"riot.tag('"+a+"', '"+b+"'"+(c?", '"+c+"'":"")+(d?", '"+d.replace(/'/g,"\\'")+"'":"")+", function(opts) {"+e+"\n});"}function H(a,b,c){if(!a)return"";var d=S.util.brackets,e=d(0),f=d(1);return a=a.replace(d(pa),'="$1"$2'),a=b.whitespace?a.replace(/\r\n?|\n/g,"\\n"):a.replace(/\s+/g," "),a=a.trim().replace(wa,""),a=a.replace(Aa,"$1riot-type="+e+'"number"'+f),a=a.replace(qa,function(a,b,c,d){return d.indexOf(e)>=0&&(b=b.toLowerCase(),na.indexOf(b)>=0?b="riot-"+b:la.indexOf(b)>=0&&(b="__"+b)),b+'="'+d+'"'}),b.expr&&(a=a.replace(d(ra),function(a,d){var g=K(d,b,c).trim().replace(/[\r\n]+/g,"").trim();return";"==g.slice(-1)&&(g=g.slice(0,-1)),e+g+f})),a=a.replace(xa,function(a,b,c){var d="<"+b+(c?" "+c.trim():"")+">";return-1==ma.indexOf(b.toLowerCase())&&(d+="</"+b+">"),d}),a=a.replace(/'/g,"\\'"),a=a.replace(d(/\\{|\\}/g),"\\$&"),b.compact&&(a=a.replace(/> </g,"><")),a}function I(a){a=a.replace(za,"").replace(ya,"");var b=a.split("\n"),c="";return b.forEach(function(a,d){var e=a.trim();if("}"!=e[0]&&~e.indexOf("(")){var f=e.match(/[{}]$/),g=f&&a.match(/^(\s+)([$\w]+)\s*\(([$\w,\s]*)\)\s*\{/);g&&!/^(if|while|switch|for|catch|function)$/.test(g[2])&&(b[d]=g[1]+"this."+g[2]+" = function("+g[3]+") {","}"==f[0]?b[d]+=" "+e.slice(g[0].length-1,-1)+"}.bind(this)":c=g[1])}a.slice(0,c.length+1)==c+"}"&&(b[d]=c+"}.bind(this);",c="")}),b.join("\n")}function J(a,b,c){return b.replace(ya,"").replace(va,function(b,c,d){return c+" "+d.split(/\s*,\s*/g).map(function(b){var c=b.trim(),d=(/:scope/.test(c)?"":" ")+c.replace(/:scope/,"");return"@"==c[0]||"from"==c||"to"==c||/%$/.test(c)?c:a+d+', [riot-tag="'+a+'"]'+d}).join(",")}).trim()}function K(a,b,c){if(!a)return"";var d=b.parser||(c?S.parsers.js[c]:I);if(!d)throw new Error('Parser not found "'+c+'"');return d(a.replace(/\r\n?/g,"\n"),b)}function L(a,b){var c=S.parsers.html[a];if(!c)throw new Error('Template parser not found "'+a+'"');return c(b.replace(/\r\n?/g,"\n"))}function M(a,b,c,d){if("scoped-css"===c)d=1;else if(S.parsers.css[c])a=S.parsers.css[c](b,a);else if("css"!==c)throw new Error('CSS parser not found: "'+c+'"');return d&&(a=J(b,a)),a.replace(/\s+/g," ").replace(/\\/g,"\\\\").replace(/'/g,"\\'").trim()}function N(a,b){return b?(b.brackets&&(S.settings.brackets=b.brackets),b.template&&(a=L(b.template,a))):b={},a=a.replace(oa,function(a,c,d){return G(c,H(d,b),"","","")}),a.replace(sa,function(a,c,d,e,f){var g="",h=b.type;return e&&(f.trim()||(e=e.replace(ta,function(a,b,c){return b&&(h=b.replace("text/","")),f=c,""})),e=e.replace(ua,function(a,b,d){var e=/(?:^|\s+)scoped(\s|=|$)/i.test(b),f=b&&b.match(/(?:^|\s+)type\s*=\s*['"]?([^'"\s]+)['"]?/i);return f&&(f=f[1].replace("text/","")),g+=(g?" ":"")+M(d.trim(),c,f||"css",e),""})),G(c,H(e,b,h),g,H(d,""),K(f,b,h))})}function O(a,b){var c=new XMLHttpRequest;c.onreadystatechange=function(){4==c.readyState&&(200==c.status||!c.status&&c.responseText.length)&&b(c.responseText)},c.open("GET",a,!0),c.send("")}function P(a){var b=/[ \t]+/.exec(a);return b&&(a=a.replace(new RegExp("^"+b[0],"gm"),"")),a}function Q(a){var b=Ba.createElement("script"),c=Ba.documentElement;b.text=N(a),c.appendChild(b),c.removeChild(b)}function R(a){function b(){ja.trigger("ready"),ka=!0,a&&a()}var c=Ba.querySelectorAll('script[type="riot/tag"]'),d=c.length;d?[].map.call(c,function(a){function c(a){Q(a),d--,d||b()}var e=a.getAttribute("src");return e?O(e,c):c(P(a.innerHTML))}):b()}var S={version:"v2.2.4",settings:{}},T=0,U="riot-",V=U+"tag",W="string",X="object",Y="undefined",Z="function",$=/^(?:opt(ion|group)|tbody|col|t[rhd])$/,_=["_item","_id","update","root","mount","unmount","mixin","isMounted","isLoop","tags","parent","opts","trigger","on","off","one"],aa=0|(a&&a.document||{}).documentMode,ba=Array.isArray;S.observable=function(a){a=a||{};var b={},c=0;return a.on=function(d,e){return m(e)&&(typeof e.id===Y&&(e._id=c++),d.replace(/\S+/g,function(a,c){(b[a]=b[a]||[]).push(e),e.typed=c>0})),a},a.off=function(c,d){return"*"==c?b={}:c.replace(/\S+/g,function(a){if(d)for(var c,e=b[a],f=0;c=e&&e[f];++f)c._id==d._id&&e.splice(f--,1);else b[a]=[]}),a},a.one=function(b,c){function d(){a.off(b,d),c.apply(a,arguments)}return a.on(b,d)},a.trigger=function(c){for(var d,e=[].slice.call(arguments,1),f=b[c]||[],g=0;d=f[g];++g)d.busy||(d.busy=1,d.apply(a,d.typed?[c].concat(e):e),f[g]!==d&&g--,d.busy=0);return b.all&&"all"!=c&&a.trigger.apply(a,["all",c].concat(e)),a},a},S.mixin=function(){var a={};return function(b,c){return c?void(a[b]=c):a[b]}}(),function(a,b,c){function d(){return h.href.split("#")[1]||""}function e(a){return a.split("/")}function f(a){a.type&&(a=d()),a!=g&&(i.trigger.apply(null,["H"].concat(e(a))),g=a)}if(c){var g,h=c.location,i=a.observable(),j=!1,k=a.route=function(a){a[0]?(h.hash=a,f(a)):i.on("H",a)};k.exec=function(a){a.apply(null,e(d()))},k.parser=function(a){e=a},k.stop=function(){j&&(c.removeEventListener?c.removeEventListener(b,f,!1):c.detachEvent("on"+b,f),i.off("*"),j=!1)},k.start=function(){j||(c.addEventListener?c.addEventListener(b,f,!1):c.attachEvent("on"+b,f),j=!0)},k.start()}}(S,"hashchange",a);var ca,da=function(a){var b,c,d,e=/[{}]/g;return function(f){var g=S.settings.brackets||a;return b!==g&&(b=g,d=g.split(" "),c=d.map(function(a){return a.replace(/(?=.)/g,"\\")})),f instanceof RegExp?g===a?f:new RegExp(f.source.replace(e,function(a){return c[~~("}"===a)]}),f.global?"g":""):d[f]}}("{ }"),ea=function(){function b(a,b){return a.indexOf(da(0))<0?(a=a.replace(/\n|\r\n?/g,"\n"),function(){return a}):(a=a.replace(da(/\\{/g),"").replace(da(/\\}/g),""),b=e(a,f(a,da(/{/),da(/}/))),a=2!==b.length||b[0]?"["+b.map(function(a,b){return b%2?c(a,!0):'"'+a.replace(/\n|\r\n?/g,"\\n").replace(/"/g,'\\"')+'"'}).join(",")+'].join("")':c(b[1]),new Function("d","return "+a.replace(/\uFFF0/g,da(0)).replace(/\uFFF1/g,da(1))+";"))}function c(a,b){return a=a.replace(/\n|\r\n?/g," ").replace(da(/^[{ ]+|[ }]+$|\/\*.+?\*\//g),""),/^\s*[\w- "']+ *:/.test(a)?"["+f(a,/["' ]*[\w- ]+["' ]*:/,/,(?=["' ]*[\w- ]+["' ]*:)|}|$/).map(function(a){return a.replace(/^[ "']*(.+?)[ "']*: *(.+?),? *$/,function(a,b,c){return c.replace(/[^&|=!><]+/g,d)+'?"'+b+'":"",'})}).join("")+'].join(" ").trim()':d(a,b)}function d(a,b){return a=a.trim(),a?"(function(v){try{v="+a.replace(i,function(a,b,c){return c?'(("'+c+h+c+")":a})+"}catch(e){}return "+(b===!0?'!v&&v!==0?"":v':"v")+"}).call(d)":""}function e(a,b){var c=[];return b.map(function(b,d){d=a.indexOf(b),c.push(a.slice(0,d),b),a=a.slice(d+b.length)}),a&&c.push(a),c}function f(a,b,c){var d,e=0,f=[],g=new RegExp("("+b.source+")|("+c.source+")","g");return a.replace(g,function(b,c,g,h){!e&&c&&(d=h),e+=c?1:-1,e||null==g||f.push(a.slice(d,h+g.length))}),f}var g={},h='"in d?d:'+(a?"window).":"global)."),i=/(['"\/])(?:[^\\]*?|\\.|.)*?\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function\s*\()|([A-Za-z_$]\w*)/g;return function(a,c){return a&&(g[a]||(g[a]=b(a)))(c)}}(),fa=function(a){function b(b){var f=b&&b.match(/^\s*<([-\w]+)/),g=f&&f[1].toLowerCase(),h=d[g]||e,i=x(h);return i.stub=!0,a&&g&&(f=g.match($))?c(i,b,g,!!f[1]):i.innerHTML=b,i}function c(a,b,c,d){var f,g=x(e),h=d?"select>":"table>";g.innerHTML="<"+h+b+"</"+h,f=g.getElementsByTagName(c)[0],f&&a.appendChild(f)}var d={tr:"tbody",th:"tr",td:"tr",tbody:"table",col:"colgroup"},e="div";return a=a&&10>a,b}(aa),ga=[],ha={};S.tag=function(a,b,c,d,e){return m(d)&&(e=d,/^[\w\-]+\s?=/.test(c)?(d=c,c=""):d=""),c&&(m(c)?e=c:E(c)),ha[a]={name:a,tmpl:b,attrs:d,fn:e},a},S.mount=function(a,b,c){function d(a){var b="";return l(a,function(a){b+=", *["+V+'="'+a.trim()+'"]'}),b}function e(){var a=Object.keys(ha);return a+d(a)}function f(a){var d;if(a.tagName){!b||(d=a.getAttribute(V))&&d==b||a.setAttribute(V,b);var e=F(a,b||a.getAttribute(V)||a.tagName.toLowerCase(),c);e&&i.push(e)}else a.length&&l(a,f)}var g,h,i=[];if(typeof b===X&&(c=b,b=0),typeof a===W?("*"===a?a=h=e():a+=d(a.split(",")),g=z(a)):g=a,"*"===b){if(b=h||e(),g.tagName)g=z(b,g);else{var j=[];l(g,function(a){j.push(z(b,a))}),g=j}b=0}return g.tagName?f(g):l(g,f),i},S.update=function(){return l(ga,function(a){a.update()})},S.mountTo=S.mount;var ia={html:{},css:{},js:{coffee:function(a){return CoffeeScript.compile(a,{bare:!0})},es6:function(a){return babel.transform(a,{blacklist:["useStrict"]}).code},none:function(a){return a}}};ia.js.javascript=ia.js.none,ia.js.coffeescript=ia.js.coffee,S.parsers=ia;var ja,ka,la="allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,draggable,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,spellcheck,translate,truespeed,typemustmatch,visible".split(","),ma="area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(","),na=["style","src","d"],oa=/^<([\w\-]+)>(.*)<\/\1>/gim,pa=/=({[^}]+})([\s\/\>]|$)/g,qa=/([\w\-]+)=(["'])([^\2]+?)\2/g,ra=/{\s*([^}]+)\s*}/g,sa=/^<([\w\-]+)\s?([^>]*)>([^\x00]*[\w\/}"']>$)?([^\x00]*?)^<\/\1>/gim,ta=/<script(?:\s+type=['"]?([^>'"]+)['"]?)?>([^\x00]*?)<\/script>/gi,ua=/<style(?:\s+([^>]+))?>([^\x00]*?)<\/style>/gi,va=/(^|\}|\{)\s*([^\{\}]+)\s*(?=\{)/g,wa=/<!--.*?-->/g,xa=/<([\w\-]+)([^>]*)\/\s*>/g,ya=/\/\*[\s\S]*?\*\//g,za=/^\s*\/\/.*$/gm,Aa=/(<input\s[^>]*?)type=['"]number['"]/gm,Ba=a.document;S.compile=function(a,c){if(typeof a===W){if("<"==a.trim()[0]){var d=P(N(a));return c||Q(d),d}return O(a,function(a){var b=P(N(a));Q(b),c&&c(b,a)})}return"function"!=typeof a&&(a=b),ka?a&&a():void(ja?a&&ja.on("ready",a):(ja=S.observable(),R(a)))};var Ca=S.mount;S.mount=function(a,b,c){var d;return S.compile(function(){d=Ca(a,b,c)}),d},S.mountTo=S.mount,S.util={brackets:da,tmpl:ea},typeof exports===X?module.exports=S:"function"==typeof define&&define.amd?define(function(){return a.riot=S}):a.riot=S}("undefined"!=typeof window?window:void 0),function(a,b){"use strict";var c={version:"v0.9.0",settings:{viewTag:".app-body",maxPageTransitionTime:200,enablePageTransitions:!1,listenPopState:!0}},d={flux:{}},e=["UCBrowser","Opera Mini"],f={BROWSER_SUPPORT:"A"};!function(a){function b(){var a=!1,b="animation",c="",d="Webkit Moz O ms Khtml".split(" "),e="",f=$("body")[0];if(void 0!==f.style.animationName&&(a=!0),a===!1)for(var g=0;g<d.length;g++)if(void 0!==f.style[d[g]+"AnimationName"]){e=d[g],b=e+"Animation",c="-"+e.toLowerCase()+"-",a=!0;break}return a}function d(){for(var a=0;e>a;a++){var b=e[a];if(-1!==navigator.userAgent.indexOf(b))return!0}return!1}function f(a){for(var b=a.target,d=0;b&&4>d;){if("A"===b.tagName){a.preventDefault();var e="mounting",f="unmount";b.getAttribute("data-pageentereffect")&&(e=b.getAttribute("data-pageentereffect").trim()),b.getAttribute("data-pageleaveeffect")&&(f=b.getAttribute("data-pageleaveeffect").trim()),c.loc(b.getAttribute("href"),e,f);break}b=b.parentNode,d+=1}}function g(a){var b=document.createEvent("CustomEvent");return b.initEvent(a),b}a.capabilities={testAnimationCapability:b,isBrowserSemiSupported:d,handleClick:f,createEvent:g}}(d),function(a){a.$=function(a,b){return document.querySelectorAll(a,b)}}(a),function(a){var b=function(){var a=this,b={};a.on=function(a,c,d){if(!(arguments.length<2||"string"!=typeof a||"function"!=typeof c)){var e=c.toString();"undefined"!=typeof b[a]?"boolean"==typeof d?b[a].callbacks[e].once=d:b[a].callbacks[e]={cb:c,once:!!d}:(b[a]={callbacks:{}},b[a].callbacks[e]={cb:c,once:!!d})}},a.once=function(b,c){a.on(b,c,!0)},a.off=function(a,c){if("string"==typeof a&&"undefined"!=typeof b[a])if("function"==typeof c){var d=c.toString(),e=b[a].callbacks[d];"undefined"!=typeof e&&delete b[a].callbacks[d]}else delete b[a]},a.trigger=function(c,d){if("string"==typeof c&&"undefined"!=typeof b[c])for(var e in b[c].callbacks){var f=b[c].callbacks[e];"function"==typeof f.cb&&f.cb(d),"boolean"==typeof f.once&&f.once===!0&&a.off(c,f.cb)}}};a.PB=b,a.Dispatcher=new b}(d),function(a){function b(){this._successCallbacks=[],this._errorCallbacks=[]}function c(a,b,c,d){c.push(function(){var c=a.apply(b,arguments);c&&"function"==typeof c.then&&c.then(d.done,d)})}b.prototype.then=function(a,d){var e;return this._isdone?e=a.apply(d,this.result):(e=new b,c(a,d,this._successCallbacks,e)),this},b.prototype["catch"]=function(a,d){var e;return this._isdone&&this._isfailure?e=a.apply(d,this.result):(e=new b,c(a,d,this._errorCallbacks,e)),this},b.prototype.resolve=function(){this.result=arguments,this._isdone=!0,this._issuccess=!0;for(var a=0;a<this._successCallbacks.length;a++)this._successCallbacks[a].apply(null,arguments);this._successCallbacks=[]},b.prototype.reject=function(){this.result=arguments,this._isdone=!0,this._isfailure=!0;for(var a=0;a<this._errorCallbacks.length;a++)this._errorCallbacks[a].apply(null,arguments);this._errorCallbacks=[]};var d={Promise:b};a.promise=d}(d),function(b){function c(a){var b="";if("string"==typeof a)b=a;else{var c=encodeURIComponent;for(var d in a)a.hasOwnProperty(d)&&(b+="&"+c(d)+"="+c(a[d]))}return b}function d(){var b;if(a.XMLHttpRequest)b=new XMLHttpRequest;else if(a.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b}function e(a,e,f,g){function h(){k.reject(n.ETIMEOUT,"AJAX:TIMEOUT",i),i.abort()}var i,j,k=new b.promise.Promise;f=f||{},g=g||{};for(var o in l)g[o]=l[o];for(var p in m)f[p]=m[p];try{i=d()}catch(q){return k.reject(n.ENOXHR,"AJAX:ABSENT"),k}j=c(f),"GET"===a&&j&&(e+="?"+j,j=null),i.open(a,e),"POST"===a?i.setRequestHeader("Content-type","application/json"):i.setRequestHeader("Content-type","*/*");for(var r in g)g.hasOwnProperty(r)&&i.setRequestHeader(r,g[r]);var s=n.ajaxTimeout;if(s)var t=setTimeout(h,s);return i.onreadystatechange=function(){if(s&&clearTimeout(t),4===i.readyState){var a=!i.status||(i.status<200||i.status>=300)&&304!==i.status;a?k.reject(i.responseText,i):k.resolve(i.responseText,i)}},i.send(j),k}function f(a){return function(b,c,d){return e(a,b,c,d)}}function g(a){l=a}function h(){return l}function i(a){m=a}function j(){return m}function k(a){"number"==typeof a&&(n.ajaxTimeout=a)}var l={},m={},n={ajax:e,get:f("GET"),post:f("POST"),put:f("PUT"),del:f("DELETE"),ENOXHR:1,ETIMEOUT:2,ajaxTimeout:15e3};b.http={},b.http.ajax=n.ajax,b.http.get=n.get,b.http.post=n.post,b.http.put=n.put,b.http["delete"]=n.del,b.httpGlobal={},b.httpGlobal.setAjaxTimeout=k,b.httpGlobal.getGlobalHeaders=h,b.httpGlobal.setGlobalHeaders=g,b.httpGlobal.getGlobalData=j,b.httpGlobal.setGlobalData=i}(d),function(a){function b(a,b){sessionStorage?sessionStorage[a]=b:g[a]=b}function c(a){return sessionStorage[a]||g[a]}function d(a,b){localStorage?localStorage[a]=b:h[a]=b}function e(a){return localStorage[a]||h[a]}function f(a){localStorage?localStorage.removeItem(a):delete h[a]}a.Storage={};var g=[];a.Storage.Session={set:b,get:c};var h=[];a.Storage.DS={set:d,get:e,removeData:f}}(d),function(a){var b=function(a,b){return b.prototype=new a,b};a.extender=b}(d),function(c,d){function e(a,b,c){return{url:b,state:a,component:c}}function g(){return r.currentState.state}function h(){var a=location.pathname.split("#")[0];if("string"==typeof a)return a;if(a.length>0)return a[0];throw new Error("Unable to process route")}function i(a){if(!(a&&a.url&&a.component))throw new Error("Route object should contain a URL regex and a component name");var b=/:([A-Za-z0-9]*)$|:(([A-Za-z0-9]*)\/)/g,c=a.url.match(b),d=a.url;if(c)for(var e=0;e<c.length;e++)c[e]=c[e].replace("/",""),d=d.replace(c[e],"(.*)");a.regex=new RegExp("^"+d+"$","i"),a.paramDictionary=c,r.routes.push(a)}function j(a,b,c){if(!b||0===b.length)return{};var d=c.match(a),e={};d.shift();for(var f=0;f<b.length;f++)e[b[f]]=d[f];return e}function k(){if(0===arguments.length)return r.currentState;if(arguments.length>0&&"string"==typeof arguments[0]){var a=arguments[0],b=h();if(history&&history.pushState){var d=!1;for(var e in r.routes){var f=r.routes[e],g=f.regex;if(g.test(a)&&r.currentState.name!==f.state){f.data=j(g,f.paramDictionary,a);var i={};i.component=f.component,i.data=f.data,i.url=f.url,i.state=f.state,""===r.currentState.name?history.replaceState(i,"",a):(f.prevPage=b,arguments[1]&&"boolean"==typeof arguments[1]&&arguments[1]===!0?history.replaceState(i,"",a):history.pushState(i,"",a)),d=!0,c.Dispatcher.trigger("veronica:stateChange",f);var k="mounting",m="unmount";arguments[1]&&"string"==typeof arguments[1]&&(k=arguments[1]),arguments[2]&&"string"==typeof arguments[2]&&(m=arguments[2]),l(f,k,m);break}}d||(location.href=a)}else a!==b&&(location.href=a)}}function l(a,c,d){if(null!==a){var e=a.component;r.currentState;r.currentState.name=a.state,r.currentState.state=a,r.currentComponent=document.createElement(e),m(c,d);b.mount(e,{})}}function m(a,b){if(a=a||"mounting",b=b||"unmount",r.viewTag)if(r.pageTag.children.length>0){var e=document.createElement("div");if(r.shownEventFired=!1,e.className="page "+r.currentComponent.tagName.toLowerCase(),e.appendChild(r.currentComponent),r.mountingComponent=e,d.settings.enablePageTransitions&&(r.pageTag.addEventListener("webkitTransitionEnd",n),r.pageTag.addEventListener("oTransitionEnd",n),r.pageTag.addEventListener("transitionend",n)),setTimeout(function(){r.shownEventFired||(o(r.pageTag,e),r.currentComponent.dispatchEvent(c.capabilities.createEvent("shown")))},d.settings.maxPageTransitionTime),"A"===f.BROWSER_SUPPORT&&d.settings.enablePageTransitions)e.classList.add(a),r.pageTag.classList.add(b),r.viewTag.appendChild(e);else{var g=r.viewTag.children&&r.viewTag.children[0],h=g&&g.children&&g.children[0];h._tag&&h._tag.isMounted&&h._tag.unmount();var i=r.currentComponent.tagName.toLowerCase(),j="<div class='page "+i+"'><"+i+"></"+i+"></div>";r.viewTag.innerHTML=j}}else r.pageTag.classList.add(r.currentComponent.tagName.toLowerCase()),r.pageTag.appendChild(r.currentComponent),c.Dispatcher.trigger("veronica:stateTransitionComplete",r.currentState.state)}function n(a){this.removeEventListener("transitionend",n),this.removeEventListener("webkitTransitionEnd",n),this.removeEventListener("oTransitionEnd",n),o(this,r.mountingComponent),r.shownEventFired=!0,r.currentComponent.dispatchEvent(c.capabilities.createEvent("shown"))}function o(a,b){a.className="hidden",q(b),b.className="page "+r.currentComponent.tagName.toLowerCase(),r.pageTag=b,c.Dispatcher.trigger("veronica:stateTransitionComplete",r.currentState.state)}function p(){return history.state?history.state.prevPage||null:null}function q(a){for(var b=r.viewTag.childNodes,c=0;b.length>1;){var d=b[c];d.childNodes[0];d!==a?d.remove?d.remove():d.parentElement&&d.parentElement.removeChild(d):c+=1}}var r={shownEventFired:!1,mountingComponent:null};r.viewTag=$(d.settings.viewTag)[0],r.viewTag?(r.viewTag.innerHTML="<div class='page'></div>",r.pageTag=r.viewTag.querySelector(".page")):r.pageTag=null,r.routes=[],r.currentState={name:"",state:{}},r.currentComponent=null,a.addEventListener("popstate",function(a){d.settings.listenPopState&&a&&a.state&&(r.currentState.state.state!==a.state.state&&c.Dispatcher.trigger("veronica:stateChange",a.state),l(a.state,"mounting-pop","unmount-pop"))}),d.createRoute=e,d.getCurrentPath=h,d.getCurrentState=g,d.getPrevPageUrl=p,d.addRoute=i,d.loc=k,c.totalRouteLength=function(){return r.routes.length}}(d,c),function(a,b,c,e){function f(){this.Dispatcher={trigger:c.trigger},this.Ajax=b,this.Promise=e}var g={};d.flux.Actions={},d.flux.Actions.createAction=function(a,b){try{return g[a]=d.extender(f,b),!0}catch(c){return!1}},d.flux.Actions.getAction=function(a){var b=g[a];return b?new b:null}}(c,d.http,d.Dispatcher,d.promise),function(a,b,c){function e(){var a=new c;this.Dispatcher={register:b.on,unregister:b.off,once:b.once},this.Storage=d.Storage,this.subscribe=a.on,this.unsubscribe=a.off,this.emit=function(b){a.trigger(b,{})}}var f={};d.flux.Stores={},d.flux.Stores.createStore=function(a,b){try{var c=d.extender(e,b);return f[a]=new c,!0}catch(g){return!1}},d.flux.Stores.getStore=function(a){return f[a]}}(c,d.Dispatcher,d.PB),function(a,c){function d(){a.capabilities.testAnimationCapability()||$("body")[0].classList.add("noanim"),a.capabilities.isBrowserSemiSupported()&&(f.BROWSER_SUPPORT="B",$("body")[0].classList.add("noanim")),b.mount("*",{}),a.totalRouteLength()>0&&(c.loc(location.pathname),a.Dispatcher.trigger("veronica:init")),document.addEventListener("click",a.capabilities.handleClick)}document.onreadystatechange=function(){"interactive"==document.readyState&&d()}}(d,c),c.flux=d.flux,c.http=d.httpGlobal,a.veronica=c}(window,riot);