ractive
Version:
Next-generation DOM manipulation
2 lines • 50.5 kB
JavaScript
(function(t){"use strict";var e,n,i,r,o,s,a,h,u,p,c,d,l,f,g,m,v,y,w,b,x,N,_,k,E,O,F,L={},M={},A={},S={},R=/^\s+/,C=/\s+$/,P="Missing Ractive.parse - cannot parse template. Either preparse or use the version that includes the parser",T=1,j=2,V=3,I=4,q=5,U=6,D=7,z=8,B=9,Y=10,$=11,H=12,X=20,J=21,Z=22,W=23,K=24,G=26,Q=30,te=31,ee=32,ne=33,ie=34,re=35,oe=36,se=40,ae={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};L.animate=function(t,n,i){var r,o,a,h,u;for(i=i||{},h=N.animations.length;h--;)N.animations[h].keypath===t&&N.animations[h].stop();i.easing&&(r="function"==typeof i.easing?i.easing:this.easing&&this.easing[i.easing]?this.easing[i.easing]:e.easing[i.easing],"function"!=typeof r&&(r=null)),o=void 0===i.duration?400:i.duration,u=s(t),a=new g({keys:u,from:this.get(u),to:n,root:this,duration:o,easing:r,step:i.step,complete:i.complete}),N.push(a)},L.bind=function(t){var e=this._bound;-1===e.indexOf(t)&&(e[e.length]=t,t.init(this))},L.fire=function(t){var e,n,i,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),n=0,i=r.length;i>n;n+=1)r[n].apply(this,e)},L.get=function(t){var e,n,i,r,o,h;if(!t)return this.data;if(a(t))e=t.slice(),n=e.join(".");else{if(this._cache.hasOwnProperty(t))return this._cache[t];e=s(t),n=e.join(".")}return this._cache.hasOwnProperty(n)?this._cache[n]:(i=e.pop(),o=e.length?this.get(e):this.data,"object"==typeof o&&o.hasOwnProperty(i)?(h=o[i],r=e.join("."),this._depsMap[r]||(this._depsMap[r]=[]),-1===this._depsMap[r].indexOf(n)&&this._depsMap[r].push(n),this.modifyArrays&&("("===n.charAt(0)||!a(h)||h.ractive&&h._ractive.setting||_(h,n,this)),this._cache[n]=h,h):void 0)};var he,ue,pe,ce,de,le;he=function(t){if(t.keypath)ce(t.root,t.keypath,t,t.priority||0);else{var e=t.root._pendingResolution.indexOf(t);-1!==e&&t.root._pendingResolution.splice(e,1)}t.evaluator&&t.evaluator.teardown()},ue=function(t,e){var n,i,r=t._depsMap[e];if(t.modifyArrays&&"("!==e.charAt(0)&&(n=t._cache[e],a(n)&&!n._ractive.setting&&k(n,e,t)),delete t._cache[e],r)for(i=r.length;i--;)ue(t,r[i])},pe=function(t,e,n,i){var r;return t._deps[e]||(t._deps[e]=[]),r=t._deps[e],r[i]?(r=r[i],-1===r.indexOf(n)&&(r[r.length]=n),void 0):(r[i]=[n],void 0)},ce=function(t,e,n,i){var r,o,s;for(r=t._deps[e][i],r.splice(r.indexOf(n),1),r.length||(t._deps[e][i]=null),o=t._deps[e].length;o--;)if(t._deps[e][o]){s=!0;break}s||(t._deps[e]=null)},de=function(t,e,n){var i,r,o,s,a,h;if(i=t._deps[e])for(a=i.length,o=0;a>o;o+=1)if(r=i[o])for(s=r.length;s--;)r[s].update();if(!n&&(h=t._depsMap[e]))for(o=h.length;o--;)de(t,h[o])},le=function(t,e,n){var i,r,o,a,h,u;if("."===e)return n[n.length-1];for(i=s(e),r=i.pop(),n=n.concat();n.length;)if(o=n.pop(),a=s(o),h=t.get(a.concat(i)),"object"==typeof h&&h.hasOwnProperty(r)){u=o+"."+e;break}return u||void 0===t.get(e)||(u=e),u},L.link=function(t){var e=this;return function(n){e.set(t,n)}},function(t){var e;t.observe=function(t,n,i){var r,o=[];if("object"==typeof t){i=n;for(r in t)t.hasOwnProperty(r)&&(n=t[r],o[o.length]=e(this,r,n,i));return{cancel:function(){for(;o.length;)o.pop().cancel()}}}return e(this,t,n,i)},e=function(t,e,n,i){var r,o,s;return i=i||{},s=i.context||t,r={update:function(){var i;i=t.get(e,!0),p(i,o)||(n.call(s,i,o),o=i)},cancel:function(){ce(t,e,r,0)}},i.init!==!1&&r.update(),pe(t,e,r,0),r}}(L),L.off=function(t,e){var n,i;e||(t?this._subs[t]=[]:this._subs={}),n=this._subs[t],n&&(i=n.indexOf(e),-1!==i&&n.splice(i,1))},L.on=function(t,e){var n,i,r=this;if("object"==typeof t){n=[];for(i in t)t.hasOwnProperty(i)&&(n[n.length]=this.on(i,t[i]));return{cancel:function(){for(;n.length;)n.pop().cancel()}}}return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){r.off(t,e)}}},L.render=function(t){var e=t.el?c(t.el):this.el;if(!e)throw Error("You must specify a DOM element to render to");t.append||(e.innerHTML=""),t.callback&&(this.callback=t.callback),this.rendered=new d({descriptor:this.template,root:this,owner:this,parentNode:e}),e.appendChild(this.rendered.docFrag)},function(t){var e,n;t.set=function(t,i){var r,o,a,u,p;if(this.setting||(this.setting=!0,this.fire("set",t,i),this.setting=!1),o=[],r=[],h(t))for(a in t)t.hasOwnProperty(a)&&(p=s(a),u=p.join("."),i=t[a],e(this,u,p,i,r,o));else p=s(t),u=p.join("."),e(this,u,p,i,r,o);if(r.length){for(;r.length;)de(this,r.pop());n(this)}for(;o.length;)de(this,o.pop(),!0);for(;this._def.length;)this._def.pop().update().deferred=!1},e=function(t,e,n,i,r,o){var s,a,h,u;if(u=n.slice(),s=t.get(e),s!==i){for(h=t.data;n.length>1;)a=n.shift(),h[a]||(h[a]=/^\s*[0-9]+\s*$/.test(n[0])?[]:{}),h=h[a];a=n[0],h[a]=i}else if("object"!=typeof i)return;for(ue(t,e),r[r.length]=e;u.length;)u.pop(),e=u.join("."),-1===o.indexOf(e)&&(o[o.length]=e)},n=function(t){var e,n,i;for(e=t._pendingResolution.length;e--;)n=t._pendingResolution.splice(e,1)[0],(i=le(t,n.ref,n.contextStack))?n.resolve(i):t._pendingResolution[t._pendingResolution.length]=n}}(L),L.teardown=function(){var t;this.rendered.teardown();for(t in this._depsMap)this._depsMap.hasOwnProperty(t)&&ue(this,t);for(t in this._cache)this._cache.hasOwnProperty(t)&&ue(this,t);for(;this._bound.length;)this.unbind(this._bound.pop())},L.unbind=function(t){var e,n=this._bound;e=n.indexOf(t),-1!==e&&(n.splice(e,1),t.teardown(this))},L.update=function(t){return ue(this,t||""),de(this,t||""),this.fire("update:"+t),this.fire("update",t),this},M.backbone=function(t,e){var n,i,r,o,s,a,h;return e&&(e+=".",s=RegExp("^"+e.replace(/\./g,"\\.")),a=e.length),{init:function(u){e?(h=function(t){var n,i;i={};for(n in t)t.hasOwnProperty(n)&&(i[e+n]=t[n]);return i},o=function(t){n||(i=!0,u.set(h(t.changed)),i=!1)},r=function(e,r){i||s.test(e)&&(n=!0,t.set(e.substring(a),r),n=!1)}):(o=function(t){n||(i=!0,u.set(t.changed),i=!1)},r=function(e,r){i||(n=!0,t.set(e,r),n=!1)}),t.on("change",o),u.on("set",r),u.set(e?h(t.attributes):t.attributes)},teardown:function(e){t.off("change",o),e.off("set",r)}}},M.statesman=function(t,e){var n,i,r,o;return e=e?e+".":"",{init:function(e){o=function(t,r){n||(i=!0,e.set(t,r),i=!1)},r=function(e,r){i||(n=!0,t.set(e,r),n=!1)},t.on("set",o),e.on("set",r),e.set(t.get())},teardown:function(e){t.off("change",o),e.off("set",r)}}},n={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}},A.tap=function(t,e){var n,i,r,o;return r=5,o=400,n=function(t){var n,i,s,a,h,u;n=t.clientX,i=t.clientY,s=this,a=function(t){e.call(s,t),u()},h=function(t){(Math.abs(t.clientX-n)>=r||Math.abs(t.clientY-i)>=r)&&u()},u=function(){window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",a)},window.addEventListener("mousemove",h),window.addEventListener("mouseup",a),setTimeout(u,o)},t.addEventListener("mousedown",n),i=function(t){var n,i,s,a,h,u,p;1===t.touches.length&&(s=t.touches[0],n=s.clientX,i=s.clientY,a=s.identifier,u=function(t){var n;n=t.changedTouches[0],n.identifier!==a&&p(),e.call(n.target,t)},h=function(t){var e;(1!==t.touches.length||t.touches[0].identifier!==a)&&p(),e=t.touches[0],(Math.abs(e.clientX-n)>=r||Math.abs(e.clientY-i)>=r)&&p()},p=function(){window.removeEventListener("touchmove",h),window.removeEventListener("touchend",u),window.removeEventListener("touchcancel",p)},window.addEventListener("touchmove",h),window.addEventListener("touchend",u),window.addEventListener("touchcancel",p),setTimeout(p,o))},{teardown:function(){t.removeEventListener("mousedown",n),t.removeEventListener("touchstart",i)}}};var fe=function(t,e){var n;for(n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(t[n]=e[n])};i=function(t){var n,i,r,o,s,a,h,u;if(n=this,o=["el","preserveWhitespace","append","twoway","modifyArrays"],s=o.concat("data","template"),t.template)if("string"==typeof t.template){if(!e.parse)throw Error(P);a=e.parse(t.template)}else a=t.template;if(t.partials){h={};for(r in t.partials)if(t.partials.hasOwnProperty(r)){if("string"==typeof t.partials[r]){if(!e.parse)throw Error(P);u=e.parse(t.partials[r],t)}else u=t.partials[r];h[r]=u}}i=function(n){var i,r;for(!n.template&&a&&(n.template=a),n.data||(n.data={}),fe(n.data,t.data),h&&(n.partials||(n.partials={}),fe(n.partials,h)),i=o.length;i--;)r=o[i],!n.hasOwnProperty(r)&&t.hasOwnProperty(r)&&(n[r]=t[r]);e.call(this,n),this.init&&this.init.call(this,n)};for(r in n.prototype)n.prototype.hasOwnProperty(r)&&(i.prototype[r]=n.prototype[r]);for(r in t)if(t.hasOwnProperty(r)&&-1===s.indexOf(r)){if(e.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');i.prototype[r]=t[r]}return i.extend=n.extend,i},r=function(t,n){return u(t)&&u(n)?e.interpolators.number(+t,+n):a(t)&&a(n)?e.interpolators.array(t,n):h(t)&&h(n)?e.interpolators.object(t,n):function(){return n}},o={number:function(t,e){var n=e-t;return n?function(e){return t+e*n}:function(){return t}},array:function(t,n){var i,r,o,s;for(i=[],r=[],s=o=Math.min(t.length,n.length);s--;)r[s]=e.interpolate(t[s],n[s]);for(s=o;t.length>s;s+=1)i[s]=t[s];for(s=o;n.length>s;s+=1)i[s]=n[s];return function(t){for(var e=o;e--;)i[e]=r[e](t);return i}},object:function(t,n){var i,r,o,s,a=[];o={},r={};for(s in t)t.hasOwnProperty(s)&&(n.hasOwnProperty(s)?(a[a.length]=s,r[s]=e.interpolate(t[s],n[s])):o[s]=t[s]);for(s in n)n.hasOwnProperty(s)&&!t.hasOwnProperty(s)&&(o[s]=n[s]);return i=a.length,function(t){for(var e,n=i;n--;)e=a[n],o[e]=r[e](t);return o}}};var ge={preserveWhitespace:!1,append:!1,twoway:!0,modifyArrays:!0,data:{}};e=function(t){var n,i,r,o,s;for(n in ge)ge.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(t[n]=ge[n]);if(this.el=c(t.el),this.data=t.data||{},this._subs={},this._cache={},this._deps={},this._depsMap={},this.nodes={},this._pendingResolution=[],this._def=[],this._proxies={},this._expressions=[],this._bound=[],t.bindings)if(a(t.bindings))for(r=0;t.bindings.length>r;r+=1)this.bind(t.bindings[r]);else this.bind(t.bindings);if(t.partials){this.partials={};for(n in t.partials)if(t.partials.hasOwnProperty(n)){if(i=t.partials[n],"string"==typeof i){if(!e.parse)throw Error(P);i=e.parse(i,t)}1===i.length&&"string"==typeof i[0]&&(i=i[0]),this.partials[n]=i}}if(o=t.template,"string"==typeof o){if(!e.parse)throw Error(P);if("#"===o.charAt(0)){if(s=document.getElementById(o.substring(1)),!s)throw Error("Could not find template element ("+o+")");this.template=e.parse(s.innerHTML,t)}else o=e.parse(o,t)}this.template=o&&1===o.length&&"string"==typeof o[0]?o[0]:o,this.el&&this.render({el:this.el,append:t.append})},g=function(t){var n;this.startTime=Date.now();for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);this.interpolator=e.interpolate(this.from,this.to),this.running=!0},g.prototype={tick:function(){var t,e,n,i;return this.running?(i=Date.now(),t=i-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.step&&this.step(1,this.to),this.complete&&this.complete(1,this.to),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,n=this.interpolator(e),this.root.set(this.keys,n),this.step&&this.step(e,n),!0)):!1},stop:function(){this.running=!1}},N={animations:[],tick:function(){var e,n;for(e=0;this.animations.length>e;e+=1)n=this.animations[e],n.tick()||this.animations.splice(e--,1);this.animations.length?t.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){N.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},function(t,e,n){var i;for(i=0;t.length>i&&!n.requestAnimationFrame;++i)n.requestAnimationFrame=n[t[i]+"RequestAnimationFrame"],n.cancelAnimationFrame=n[t[i]+"CancelAnimationFrame"]||n[t[i]+"CancelRequestAnimationFrame"];n.requestAnimationFrame||(n.requestAnimationFrame=function(t){var i,r,o;return i=Date.now(),r=Math.max(0,16-(i-e)),o=n.setTimeout(function(){t(i+r)},r),e=i+r,o}),n.cancelAnimationFrame||(n.cancelAnimationFrame=function(t){n.clearTimeout(t)})}(["ms","moz","webkit","o"],0,t),function(){var t,e,n,i,r,o,s;t=Object.defineProperty?Object.defineProperty:function(t,e,n){t[e]=n.value},_=function(e,i,r){var o,s,a,h;e._ractive?(o=e._ractive.roots,s=e._ractive.keypathsByIndex,a=o.indexOf(r),-1===a&&(a=o.length,o[a]=r),s[a]||(s[a]=[]),h=s[a],-1===h.indexOf(i)&&(h[h.length]=i)):(t(e,"_ractive",{value:{roots:[r],keypathsByIndex:[[i]]},configurable:!0}),n(e))},k=function(t,e,n){var r,o,s,a,h;if(!t._ractive)throw Error("Attempted to remove keypath from non-wrapped array. This error is unexpected - please send a bug report to @rich_harris");if(r=t._ractive.roots,s=r.indexOf(n),-1===s)throw Error("Ractive instance was not listed as a dependent of this array. This error is unexpected - please send a bug report to @rich_harris");if(o=t._ractive.keypathsByIndex,a=o[s],h=a.indexOf(e),-1===h)throw Error("Attempted to unlink non-linked keypath from array. This error is unexpected - please send a bug report to @rich_harris");a.splice(h,1),a.length||r.splice(s,1),r.length||i(t)},e=function(t){var e,n,i,r,o,s;for(e=t._ractive.roots,n=t._ractive.keypathsByIndex,o=e.length;o--;)for(i=e[o],r=n[o],s=r.length;s--;)i.set(r[s],t)},r=[],s=["pop","push","reverse","shift","sort","splice","unshift"],s.forEach(function(n){var i=function(){var t=Array.prototype[n].apply(this,arguments);return this._ractive.setting=!0,e(this),this._ractive.setting=!1,t};t(r,n,{value:i})}),o={},o.__proto__?(n=function(t){t.__proto__=r},i=function(t){delete t._ractive,t.__proto__=Array.prototype}):(n=function(e){var n,i;for(n=s.length;n--;)i=s[n],t(e,i,{value:r[i]})},i=function(t){var e;for(e=s.length;e--;)delete t[s[e]];delete t._ractive})}(),function(t,e){var n,i;i=function(t,n){var i,r;if(e[t])return e[t];for(r=[];n--;)r[n]="_"+n;return i=Function(r.join(","),"return("+t+")"),e[t]=i,i},f=function(t,e,i,r,o){var s;if(this.root=t,this.mustache=e,this.priority=e.priority,this.str=o.s,this.keypaths=[],this.override=[],this.values=[],o.r){for(this.resolvers=[],this.unresolved=this.numRefs=s=o.r.length;s--;)r&&r.hasOwnProperty(o.r[s])?(this.values[s]=this.override[s]=r[o.r[s]],this.unresolved-=1):this.resolvers[this.resolvers.length]=new n(t,o.r[s],i,s,this);1>=this.resolvers.length&&(this.selfUpdating=!0),this.unresolved||this.resolved||this.init()}else this.init()},f.prototype={init:function(){var t,e=this;this.resolved=!0,this.keypath="("+this.str.replace(/❖([0-9]+)/g,function(t,n){return e.override.hasOwnProperty(n)?e.override[n]:e.keypaths[n]})+")",-1===this.root._expressions.indexOf(this.keypath)?(t=this.str.replace(/❖([0-9]+)/g,function(t,e){return"_"+e}),this.fn=i(t,this.numRefs||0),this.update(),this.root._expressions.push(this.keypath)):this.teardown(),this.mustache.resolve(this.keypath)},teardown:function(){if(this.resolvers)for(;this.resolvers.length;)this.resolvers.pop().teardown()},resolve:function(t,e,n){this.keypaths[e]=n,this.unresolved-=1,this.unresolved||this.init()},bubble:function(){this.selfUpdating?this.update():!this.deferred&&this.resolved&&(this.root._def[this.root._def.length]=this,this.deferred=!0)},update:function(){var t;if(!this.resolved)return this;try{t=this.getter()}catch(e){if(this.root.debug)throw e;t=void 0}return p(t,this._lastValue)||(ue(this.root,this.keypath),this.root._cache[this.keypath]=t,de(this.root,this.keypath),this._lastValue=t),this},getter:function(){return this.fn.apply(null,this.values)}},n=function(t,e,n,i,r){var o;this.ref=e,this.root=t,this.evaluator=r,this.priority=r.priority,this.argNum=i,o=le(t,e,n),o?this.resolve(o):(this.contextStack=n,t._pendingResolution[t._pendingResolution.length]=this)},n.prototype={teardown:function(){he(this)},resolve:function(t){this.keypath=t,pe(this.root,t,this,this.priority),this.update(),this.evaluator.resolve(this.ref,this.argNum,t)},update:function(){var t=this.root.get(this.keypath);p(t,this._lastValue)||(this.evaluator.values[this.argNum]=t,this.evaluator.bubble(),this._lastValue=t)}}}({},{}),b=function(t,e){var n,i,r,o,s;if(t.owner=e.owner,t.owner.type===I&&(t.index=e.index),t.owner.parentFragment&&(o=t.owner.parentFragment.indexRefs)){t.indexRefs={};for(s in o)o.hasOwnProperty(s)&&(t.indexRefs[s]=o[s])}for(e.indexRef&&(t.indexRefs||(t.indexRefs={}),t.indexRefs[e.indexRef]=e.index),t.items=[],r={root:e.root,parentFragment:t,parentNode:e.parentNode,contextStack:e.contextStack},n=e.descriptor?e.descriptor.length:0,i=0;n>i;i+=1)r.descriptor=e.descriptor[i],r.index=i,t.items[t.items.length]=t.createItem(r)},m=function(t,e){var n,i;t.root=e.root,t.descriptor=e.descriptor,t.parentFragment=e.parentFragment,t.contextStack=e.contextStack||[],t.index=e.index||0,t.priority=e.descriptor.p||0,(e.parentNode||e.anchor)&&(t.parentNode=e.parentNode,t.anchor=e.anchor),t.type=e.descriptor.t,e.descriptor.r&&(t.parentFragment.indexRefs&&t.parentFragment.indexRefs.hasOwnProperty(e.descriptor.r)?(i=t.parentFragment.indexRefs[e.descriptor.r],t.render(i)):(n=le(t.root,e.descriptor.r,t.contextStack),n?t.resolve(n):(t.ref=e.descriptor.r,t.root._pendingResolution[t.root._pendingResolution.length]=t,t.descriptor.n&&t.render(!1)))),e.descriptor.x&&(t.evaluator=new f(t.root,t,t.contextStack,t.parentFragment.indexRefs,e.descriptor.x))},v=function(){var t;this.keypath?t=this.root.get(this.keypath,!0):this.expression&&(t=this.evaluate()),p(t,this._lastValue)||(this.render(t),this._lastValue=t)},y=function(t){this.keypath=t,pe(this.root,t,this,this.priority),this.update()},w=function(){var t,e;for(t=[],e=this.refs.length;e--;)t[e]=this.root.get(this.refs[e]);return this.evaluator.apply(null,t)},x=function(t,e){var n,i,r,o,s;if(n={descriptor:t.descriptor.f,root:t.root,parentNode:t.parentNode,owner:t},i=a(e),i&&0===e.length&&(r=!0),t.descriptor.n){if(e&&!r)t.length&&(t.unrender(),t.length=0);else if(!t.length)return n.contextStack=t.contextStack,n.index=0,t.fragments[0]=t.createFragment(n),t.length=1,void 0}else if(i){if(e.length<t.length)for(s=t.fragments.splice(e.length,t.length-e.length);s.length;)s.pop().teardown();else if(e.length>t.length)for(o=t.length;e.length>o;o+=1)n.contextStack=t.contextStack.concat(t.keypath+"."+o),n.index=o,t.descriptor.i&&(n.indexRef=t.descriptor.i),t.fragments[o]=t.createFragment(n);t.length=e.length}else h(e)?t.length||(n.contextStack=t.contextStack.concat(t.keypath),n.index=0,t.fragments[0]=t.createFragment(n),t.length=1):e&&!r?t.length||(n.contextStack=t.contextStack,n.index=0,t.fragments[0]=t.createFragment(n),t.length=1):t.length&&(t.unrender(),t.length=0)},function(){var t,n,i,r,o,s,a,h,u,p;i={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},n="undefined"!=typeof window?window.document:null,t=function(t,e){var i,r=[];for(i=n.createElement("div"),i.innerHTML=t;i.firstChild;)r[r.length]=i.firstChild,e.appendChild(i.firstChild);return r},d=function(e){return this.docFrag=n.createDocumentFragment(),"string"==typeof e.descriptor?(this.nodes=t(e.descriptor,this.docFrag),void 0):(b(this,e),void 0)},d.prototype={createItem:function(t){if("string"==typeof t.descriptor)return new r(t,this.docFrag);switch(t.descriptor.t){case j:return new h(t,this.docFrag);case I:return new p(t,this.docFrag);case V:return new u(t,this.docFrag);case D:return new o(t,this.docFrag);case z:return new s(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},s=function(t,e){this.parentFragment=t.parentFragment,this.fragment=new d({descriptor:t.root.partials[t.descriptor.r]||[],root:t.root,parentNode:t.parentNode,contextStack:t.contextStack,owner:this}),e.appendChild(this.fragment.docFrag)},s.prototype={teardown:function(){this.fragment.teardown()}},r=function(t,e){this.node=n.createTextNode(t.descriptor),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},r.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(t,e){var i,r,o,s,h,u,p,c;if(i=this.descriptor=t.descriptor,this.root=t.root,this.parentFragment=t.parentFragment,this.parentNode=t.parentNode,this.index=t.index,this.eventListeners=[],this.customEventListeners=[],i.a&&i.a.xmlns){if(r=i.a.xmlns,"string"!=typeof r)throw Error("Namespace attribute cannot contain mustaches")}else r=this.parentNode.namespaceURI;if(this.node=n.createElementNS(r,i.e),i.f&&("string"==typeof i.f&&this.node.namespaceURI===ae.html?this.node.innerHTML=i.f:(this.fragment=new d({descriptor:i.f,root:t.root,parentNode:this.node,contextStack:t.contextStack,owner:this}),this.node.appendChild(this.fragment.docFrag))),i.v)for(o in i.v)i.v.hasOwnProperty(o)&&this.addEventProxy(o,i.v[o],t.contextStack);this.attributes=[],p=[];for(h in i.a)i.a.hasOwnProperty(h)&&(u=i.a[h],s=new a({element:this,name:h,value:void 0===u?null:u,root:t.root,parentNode:this.node,contextStack:t.contextStack}),this.attributes[this.attributes.length]=s,s.isBindable&&p.push(s),s.isTwowayNameAttr?c=s:s.update());for(;p.length;)p.pop().bind(this.root.lazy);c&&(c.updateViewModel(),c.update()),e.appendChild(this.node)},o.prototype={addEventProxy:function(t,n,i){var r,o,s,a,h=this,u=this.root;"string"==typeof n?(u._proxies[n]||(u._proxies[n]=function(t){u.fire(n,t,this)}),a=u._proxies[n]):(s=new l({descriptor:n,root:this.root,owner:this,contextStack:i}),a=function(t){u.fire(""+s,t,h.node)}),(r=e.eventDefinitions[t])?(o=r(this.node,a),this.customEventListeners[this.customEventListeners.length]=o):void 0!==this.node["on"+t]?(this.eventListeners[this.eventListeners.length]={n:t,h:a},this.node.addEventListener(t,a)):console&&console.warn&&console.warn("Invalid event handler ("+t+")")},teardown:function(){var t;for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.fragment&&this.fragment.teardown();this.attributes.length;)this.attributes.pop().teardown();for(;this.eventListeners.length;)t=this.eventListeners.pop(),this.node.removeEventListener(t.n,t.h);for(;this.customEventListeners.length;)this.customEventListeners.pop().teardown()},firstNode:function(){return this.node},bubble:function(){}},a=function(t){var e,n,r,o,s,a,h,u,p,c,d;if(e=t.name,n=t.value,this.element=t.element,r=e.indexOf(":"),-1!==r&&(o=e.substr(0,r),"xmlns"!==o&&(e=e.substring(r+1),this.namespace=ae[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';if(null===n||"string"==typeof n)return this.namespace?t.parentNode.setAttributeNS(this.namespace,e,n):t.parentNode.setAttribute(e,n),"id"===e.toLowerCase()&&(t.root.nodes[n]=t.parentNode),void 0;for(this.root=t.root,this.parentNode=t.parentNode,this.name=e,this.lcName=e.toLowerCase(),this.namespace||t.parentNode.namespaceURI!==ae.html||(h=this.lcName,u=i[h]||h,void 0!==t.parentNode[u]&&(this.propertyName=u),("boolean"==typeof t.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.element.parentFragment,this.fragment=new l({descriptor:n,root:this.root,owner:this,contextStack:t.contextStack}),this.selfUpdating=!0,p=this.fragment.items.length;p--;)if(c=this.fragment.items[p],c.type!==T){if(c.type!==j){this.selfUpdating=!1;break}if(d){this.selfUpdating=!1;break}d=!0}this.root.twoway&&(s=this.element.descriptor.e.toLowerCase(),a=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==s&&"textarea"!==s&&"select"!==s)),a&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0},a.prototype={bind:function(t){var e,n,i,r,o,s=this,a=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==j)throw"Not a valid two-way data binding candidate - must be a single interpolator";if(this.interpolator=this.fragment.items[0],e=this.interpolator.keypath||this.interpolator.descriptor.r,"SELECT"===a.tagName&&"value"===this.propertyName)for(n=a.getElementsByTagName("option"),o=n.length,r=0;o>r;r+=1)if(i=n[r],i.hasAttribute("selected")){this.root.set(e,i.value);break}"checkbox"===a.type||"radio"===a.type?"name"===this.propertyName?(a.name="{{"+e+"}}",this.updateViewModel=function(){a.checked&&s.root.set(e,a.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){s.root.set(e,a.checked)}):this.updateViewModel=function(){var t;t=a.value,"0"===t?t=0:""!==t&&(t=+t||t),s.root.set(e,t)},this.updateViewModel&&(this.twoway=!0,a.addEventListener("change",this.updateViewModel),a.addEventListener("click",this.updateViewModel),a.addEventListener("blur",this.updateViewModel),t||(a.addEventListener("keyup",this.updateViewModel),a.addEventListener("keydown",this.updateViewModel),a.addEventListener("keypress",this.updateViewModel),a.addEventListener("input",this.updateViewModel)))},teardown:function(){this.updateViewModel&&(this.parentNode.removeEventListener("change",this.updateViewModel),this.parentNode.removeEventListener("click",this.updateViewModel),this.parentNode.removeEventListener("blur",this.updateViewModel),this.parentNode.removeEventListener("keyup",this.updateViewModel),this.parentNode.removeEventListener("keydown",this.updateViewModel),this.parentNode.removeEventListener("keypress",this.updateViewModel),this.parentNode.removeEventListener("input",this.updateViewModel)),this.fragment&&this.fragment.teardown()},bubble:function(){this.selfUpdating?this.update():!this.deferred&&this.ready&&(this.root._def[this.root._def.length]=this,this.deferred=!0)},update:function(){var t,e;if(!this.ready)return this;if("id"===this.lcName&&(void 0!==this.id&&delete this.root.nodes[this.id],this.root.nodes[this.id]=this.parentNode),this.twoway){if(e=this.lcName,this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(n.activeElement===this.parentNode)return this}if(t=""+this.fragment,void 0===t&&(t=""),t!==this.value){if(this.useProperty)return this.parentNode[this.propertyName]=t,this;if(this.namespace)return this.parentNode.setAttributeNS(this.namespace,this.name,t),this;this.parentNode.setAttribute(this.name,t),this.value=t}return this}},h=function(t,e){this.node=n.createTextNode(""),e.appendChild(this.node),m(this,t),this.cond&&!this.keypath&&this.update(!1)},h.prototype={update:v,resolve:y,evaluate:w,teardown:function(){he(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},render:function(t){this.node.data=t},firstNode:function(){return this.node}},u=function(t,e){this.nodes=[],this.docFrag=n.createDocumentFragment(),this.initialising=!0,m(this,t),e.appendChild(this.docFrag),this.initialising=!1},u.prototype={update:v,resolve:y,evaluate:w,teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());he(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},render:function(e){for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=t(e,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}},p=function(t,e){this.fragments=[],this.length=0,this.docFrag=n.createDocumentFragment(),this.initialising=!0,m(this,t),e.appendChild(this.docFrag),this.initialising=!1},p.prototype={update:v,resolve:y,evaluate:w,teardown:function(){this.unrender(),he(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},render:function(t){x(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var e=new d(t);return this.docFrag.appendChild(e.docFrag),e}}}(),function(){var t,e,n,i;r=function r(t){b(this,t)},r.prototype={createItem:function(r){if("string"==typeof r.descriptor)return new t(r.descriptor);switch(r.descriptor.t){case j:return new e(r);case V:return new n(r);case I:return new i(r);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.owner.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},toString:function(){return this.items.join("")}},t=function(t){this.text=t},t.prototype={toString:function(){return this.text},teardown:function(){}},e=function(t){m(this,t),this.cond&&!this.keypath&&this.update(!1)},e.prototype={update:v,resolve:y,evaluate:w,render:function(t){this.value=t,this.parentFragment.bubble()},teardown:function(){he(this)},toString:function(){return void 0===this.value?"":this.value}},n=e,i=function(t){this.fragments=[],this.length=0,m(this,t)},i.prototype={update:v,resolve:y,evaluate:w,teardown:function(){this.unrender(),he(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parentFragment.bubble()},render:function(t){x(this,t),this.parentFragment.bubble()},createFragment:function(t){return new r(t)},toString:function(){return this.fragments.join("")}}}(),s=function(t){var e,n,i,r,o;if(S[t])return S[t].concat();for(i=[],r=t,n=0;r.length;){if(e=r.indexOf(".",n),-1===e)o=r,r="";else{if("\\"===r.charAt(e-1)&&"\\"!==r.charAt(e-2)){n=e+1;continue}o=r.substr(0,e),n=0}/\[/.test(o)?i=i.concat(o.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):i[i.length]=o,r=r.substring(e+1)}return S[t]=i,i.concat()},a=function(t){return"[object Array]"===Object.prototype.toString.call(t)},p=function(t,e){return null===t&&null===e?!0:"object"==typeof t||"object"==typeof e?!1:t===e},u=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},h=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},c=function(t){var e,n;if("undefined"!=typeof window){if(n=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=n.getElementById(t),!e&&n.querySelector&&(e=n.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},E=function(t){var e,n,i,r;for(e=0;t.length>e;e+=1)n=t[e],i=t[e-1],r=t[e+1],(n.mustacheType===B||n.mustacheType===Y)&&(t.splice(e,1),i&&r&&i.type===T&&r.type===T&&(i.value+=r.value,t.splice(e,1)),e-=1);return t},O=function(t){var e,n,i;for(i="";t.length;){if(e=t.indexOf("<!--"),n=t.indexOf("-->"),-1===e&&-1===n){i+=t;break}if(-1!==e&&-1===n)throw"Illegal HTML - expected closing comment sequence ('-->')";if(-1!==n&&-1===e||e>n)throw"Illegal HTML - unexpected closing comment sequence ('-->')";i+=t.substr(0,e),t=t.substring(n+3)}return i},F=function(t){var e,n,i,r,o,s;for(o=/^\s*\r?\n/,s=/\r?\n\s*$/,e=2;t.length>e;e+=1)n=t[e],i=t[e-1],r=t[e-2],n.type===T&&i.type===$&&r.type===T&&s.test(r.value)&&o.test(n.value)&&(i.mustacheType!==j&&i.mustacheType!==V&&(r.value=r.value.replace(s,"\n")),n.value=n.value.replace(o,""),""===n.value&&t.splice(e--,1));return t};var me;(function(){var t,e,n,i,r,o,s,a,h,u,p,c;me=function(t,e,n,i){var o,s;return o={pos:0,tokens:t||[],next:function(){return o.tokens[o.pos]},options:n},s=new r(o,e,i)},t=function(t,r,o){return t.next()?e(t,o)||n(t,r,o)||i(t,r,o):null},e=function(t,e){var n=t.next();return n.type===T?(t.pos+=1,new o(n,e)):null
},n=function(t,e,n){var i=t.next();return i.type===$||i.type===V?i.mustacheType===I||i.mustacheType===q?new a(i,t,e,n):new s(i,t,e):null},i=function(t,e,n){var i,r=t.next();return r.type===H?(i=new h(r,t,e,n),t.options.sanitize&&t.options.sanitize.elements&&-1!==t.options.sanitize.elements.indexOf(i.lcTag)?null:i):null},p=function(t){var e,n,i,r="";if(!t)return"";for(n=0,i=t.length;i>n;n+=1){if(e=""+t[n],e===!1)return!1;r+=e}return r},c=function(t,e){var n,i;return e||(n=p(t),n===!1)?i=t.map(function(t){return t.toJson(e)}):n},r=function(e,n,i){var r,o;for(r=this.items=[],o=t(e,n,i);null!==o;)r[r.length]=o,o=t(e,n,i)},r.prototype={toJson:function(t){var e=c(this.items,t);return e},toString:function(){var t=p(this.items);return t}},function(){var t,e,n;o=function(t,e){this.type=T,this.text=e?t.value:t.value.replace(n," ")},o.prototype={toJson:function(){return this.decoded||(this.decoded=e(this.text))},toString:function(){return this.text}},t={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},e=function(e){var n;return n=e.replace(/&([a-zA-Z]+);/,function(e,n){return t[n]?String.fromCharCode(t[n]):e}),n=n.replace(/&#x([0-9]+);/,function(t,e){return String.fromCharCode(parseInt(e,16))}),n=n.replace(/&#([0-9]+);/,function(t,e){return String.fromCharCode(e)})},n=/\s+/g}(),function(){s=function(t,e,n){this.type=t.type===V?V:t.mustacheType,t.ref&&(this.ref=t.ref),t.expression&&(this.expr=new u(t.expression)),this.priority=n,e.pos+=1},s.prototype={toJson:function(){var t;return this.json?this.json:(t={t:this.type},this.ref&&(t.r=this.ref),this.expr&&(t.x=this.expr.toJson()),this.priority&&(t.p=this.priority),this.json=t,t)},toString:function(){return!1}},a=function(e,n,i,r){var o;for(this.ref=e.ref,this.indexRef=e.indexRef,this.priority=i||0,this.inverted=e.mustacheType===q,e.expression&&(this.expr=new u(e.expression)),n.pos+=1,this.items=[],o=n.next();o;){if(o.mustacheType===U){if(o.ref===this.ref||o.expr&&this.expr){n.pos+=1;break}throw Error("Could not parse template: Illegal closing section")}this.items[this.items.length]=t(n,this.priority+1,r),o=n.next()}},a.prototype={toJson:function(t){var e;return this.json?this.json:(e={t:I},this.ref&&(e.r=this.ref),this.indexRef&&(e.i=this.indexRef),this.inverted&&(e.n=!0),this.expr&&(e.x=this.expr.toJson()),this.items.length&&(e.f=c(this.items,t)),this.priority&&(e.p=this.priority),this.json=e,e)},toString:function(){return!1}}}(),function(){var e,n,i,r,o,s,a;h=function(n,i,h,u){var p,c,d,l,f;if(this.tag=n.name,this.lcTag=this.tag.toLowerCase(),this.priority=h=h||0,i.pos+=1,u=u||"pre"===this.lcTag,n.attrs&&(c=n.attrs.filter(s),d=n.attrs.filter(a),i.options.sanitize&&i.options.sanitize.eventAttributes&&(c=c.filter(o)),l=function(t){return{name:t.name,value:me(t.value,h+1)}},c.length&&(this.attributes=c.map(l)),d.length&&(this.proxies=d.map(l))),n.selfClosing&&(this.selfClosing=!0),-1!==e.indexOf(this.lcTag)&&(this.isVoid=!0),!this.selfClosing&&!this.isVoid){for(this.siblings=r[this.lcTag],this.items=[],p=i.next();p&&p.mustacheType!==U;){if(p.type===H){if(p.closing){p.name.toLowerCase()===this.lcTag&&(i.pos+=1);break}if(this.siblings&&-1!==this.siblings.indexOf(p.name.toLowerCase()))break}this.items[this.items.length]=t(i,this.priority+1),p=i.next()}u||(f=this.items[0],f&&f.type===T&&(f.text=f.text.replace(R,""),f.text||this.items.shift()),f=this.items[this.items.length-1],f&&f.type===T&&(f.text=f.text.replace(C,""),f.text||this.items.pop()))}},h.prototype={toJson:function(t){var e,n,i,r,o;if(e={t:D,e:this.tag},this.attributes&&this.attributes.length)for(e.a={},o=this.attributes.length,r=0;o>r;r+=1)n=this.attributes[r].name,void 0===this.attributes[r].value&&(i=null),i=c(this.attributes[r].value.items,t),e.a[n]=i;if(this.items&&this.items.length&&(e.f=c(this.items,t)),this.proxies&&this.proxies.length)for(e.v={},o=this.proxies.length,r=0;o>r;r+=1)n=this.proxies[r].name,i=c(this.proxies[r].value.items,t),e.v[n]=i;return this.json=e,e},toString:function(){var t,i,r,o,s,a,h;if(void 0!==this.str)return this.str;if(-1===n.indexOf(this.tag.toLowerCase()))return this.str=!1;if(a=p(this.items),a===!1)return this.str=!1;if(this.proxies)return this.str=!1;if(h=-1!==e.indexOf(this.tag.toLowerCase()),t="<"+this.tag,this.attributes)for(i=0,r=this.attributes.length;r>i;i+=1){if(-1!==this.attributes[i].name.indexOf(":"))return this.str=!1;if("id"===this.attributes[i].name.toLowerCase())return this.str=!1;if(o=" "+this.attributes[i].name,void 0!==this.attributes[i].value){if(s=""+this.attributes[i].value,s===!1)return this.str=!1;""!==s&&(o+="=",o+=/[\s"'=<>`]/.test(s)?'"'+s.replace(/"/g,""")+'"':s)}t+=o}return this.selfClosing&&!h?(t+="/>",this.str=t):(t+=">",h?this.str=t:(t+=a,t+="</"+this.tag+">",this.str=t))}},e="area base br col command embed hr img input keygen link meta param source track wbr".split(" "),n="a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt em fieldset font form frame frameset h1 h2 h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta noframes noscript object ol optgroup option p param pre q s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var article aside audio bdi canvas command data datagrid datalist details embed eventsource figcaption figure footer header hgroup keygen mark meter nav output progress ruby rp rt section source summary time track video wbr".split(" "),i="li dd rt rp optgroup option tbody tfoot tr td th".split(" "),r={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:"address article aside blockquote dir div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr menu nav ol p pre section table ul".split(" "),rt:["rt","rp"],rp:["rp","rt"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tr:["tr"],td:["td","th"],th:["td","th"]},o=function(t){return"on"!==t.name.substr(0,2)},s=function(t){return"proxy-"!==t.name.substr(0,6)},a=function(t){return"proxy-"===t.name.substr(0,6)?(t.name=t.name.substring(6),!0):!1}}(),function(){var t,e;u=function(n){this.refs=[],t(n,this.refs),this.str=e(n,this.refs)},u.prototype={toJson:function(){return{r:this.refs,s:this.str}}},t=function(e,n){var i;if(e.t===Q&&-1===n.indexOf(e.n)&&(n[n.length]=e.n),e.o)for(i=e.o.length;i--;)t(e.o[i],n);e.x&&t(e.x,n),e.r&&t(e.r,n)},e=function(t,n){var i=function(t){return e(t,n)};switch(t.t){case K:case G:case X:return t.v;case J:return'"'+t.v.replace(/"/g,'\\"')+'"';case Z:return"["+t.m.map(i).join(",")+"]";case ne:return t.s+e(t.x,n);case oe:return e(t.o[0],n)+t.s+e(t.o[1],n);case se:return e(t.x,n)+"("+(t.o?t.o.map(i).join(","):"")+")";case ie:return"("+e(t.x,n)+")";case ee:return e(t.x,n)+e(t.r,n);case te:return t.n?"."+t.n:"["+e(t.x,n)+"]";case re:return e(t.o[0],n)+"?"+e(t.o[1],n)+":"+e(t.o[2],n);case Q:return"❖"+n.indexOf(t.n);default:throw Error("Could not stringify expression token. This error is unexpected")}}}()})();var ve;(function(){var t,e,n,i,r,o,s,a,h,u,p,c,d,l,f,g,m,v,y,w,b,x,N;ve=function(t){var e=i(t)||r(t)||o(t)||s(t);return e},N=function(t,e){var n=t.remaining().substr(0,40);throw 40===n.length&&(n+="..."),Error('Tokenizer failed: unexpected string "'+n+'" (expected '+e+")")},t=function(t,e){var n;return n=t.str.substr(t.pos,e.length),n===e?(t.pos+=e.length,e):null},e=function(t){return function(e){var n=t.exec(e.str.substring(e.pos));return n?(e.pos+=n[0].length,n[1]||n[0]):null}},n=function(t){var e=R.exec(t.str.substring(t.pos));return e?(t.pos+=e[0].length,e[0]):null},h=e(/^[^\s=]+/),u=function(e){var i,r,o;return t(e,"=")?(i=e.pos,n(e),(r=h(e))?(n(e),(o=h(e))?(n(e),t(e,"=")?[r,o]:(e.pos=i,null)):(e.pos=i,null)):(e.pos=i,null)):null},p=e(/^[a-zA-Z_$][a-zA-Z_$0-9]*/),c=function(e){var n,i,r;if(n=e.pos,t(e,"."))return".";if(i=p(e),!i)return null;for(r=d(e);null!==r;)i+=r,r=d(e);return i},d=function(t){return l(t)||f(t)},l=e(/^\.[a-zA-Z_$][a-zA-Z_$0-9]*/),f=function(t){var e=g(t);return e?"."+e:null},g=e(/^\[(0|[1-9][0-9]*)\]/),m=function(t){var e,n,i,r,o;if(e=t.pos,n="",i=b(t),i&&(n+=i),r=v(t),r&&(n+=r),n)for(o=m(t);o;)n+=o,o=m(t);return n},v=e(/^[^\\']+/),y=function(t){var e,n,i,r,o;if(e=t.pos,n="",i=b(t),i&&(n+=i),r=w(t),r&&(n+=r),!n)return"";for(o=y(t);""!==o;)n+=o;return n},w=e(/^[^\\"]+/),b=function(t){var e,n="";for(e=x(t);e;)n+=e,e=x(t);return n||null},x=function(e){var n;return t(e,"\\")?(n=e.str.charAt(e.pos),e.pos+=1,n):null},function(){var r,o,s,h;i=function(e){var i,o=e.pos;return t(e,e.delimiters[0])?(i=u(e))?t(e,e.delimiters[1])?(e.delimiters=i,{type:$,mustacheType:Y}):(e.pos=o,null):(i=r(e),null===i?(e.pos=o,null):(n(e),t(e,e.delimiters[1])||N(e,'"'+e.delimiters[1]+'"'),i)):null},r=function(e){var i,r,h,u,p,d,l;if(i=e.pos,r={type:$},h=o(e),r.mustacheType=h||j,h===B&&(d=e.remaining(),l=d.indexOf(e.delimiters[1]),-1!==l))return e.pos+=l,r;if(n(e),t(e,"("))n(e),u=a(e),n(e),t(e,")")||N(e,'")"'),r.expression=u;else if(r.ref=c(e),!r.ref)return e.pos=i,null;return p=s(e),null!==p&&(r.indexRef=p),r},h={"#":I,"^":q,"/":U,">":z,"!":B,"&":j},o=function(t){var e=h[t.str.charAt(t.pos)];return e?(t.pos+=1,e):null},s=e(/^\s*:\s*([a-zA-Z_$][a-zA-Z_$0-9]*)/)}(),function(){r=function(e){var i,r=e.pos;return t(e,e.tripleDelimiters[0])?(i=u(e))?t(e,e.delimiters[1])?(e.tripleDelimiters=i,{type:Y}):(e.pos=r,null):(n(e),i=c(e),null===i?(e.pos=r,null):(n(e),t(e,e.tripleDelimiters[1])?{type:V,ref:i}:(e.pos=r,null))):null}}(),function(){var r,s,a,h,u,p,c,d,l,f,g,v,w,b;o=function(t){return r(t)||s(t)},r=function(e){var n,i,r;return n=e.pos,t(e,"<")?(i={type:H},i.name=a(e),i.name?(r=h(e),r&&(i.attrs=r),t(e,"/")&&(i.selfClosing=!0),t(e,">")?i:(e.pos=n,null)):(e.pos=n,null)):null},s=function(e){var n,i;if(n=e.pos,!t(e,"<"))return null;if(i={type:H,closing:!0},!t(e,"/"))throw Error("Unexpected character "+e.remaining().charAt(0)+' (expected "/")');if(i.name=a(e),!i.name)throw Error("Unexpected character "+e.remaining().charAt(0)+" (expected tag name)");if(!t(e,">"))throw Error("Unexpected character "+e.remaining().charAt(0)+' (expected ">")');return i},a=e(/^[a-zA-Z][a-zA-Z0-9]*/),h=function(t){var e,i,r;if(e=t.pos,n(t),r=u(t),!r)return t.pos=e,null;for(i=[];null!==r;)i[i.length]=r,n(t),r=u(t);return i},u=function(t){var e,n,i;return(n=p(t))?(e={name:n},i=c(t),i&&(e.value=i),e):null},p=e(/^[^\s"'>\/=]+/),c=function(e){var i,r;return i=e.pos,n(e),t(e,"=")?(r=g(e)||w(e)||d(e),null===r?(e.pos=i,null):r):(e.pos=i,null)},f=e(/^[^\s"'=<>`]+/),l=function(t){var e,n,i;return e=t.pos,(n=f(t))?(-1!==(i=n.indexOf(t.delimiters[0]))&&(n=n.substr(0,i),t.pos=e+n.length),{type:T,value:n}):null},d=function(t){var e,n;for(e=[],n=i(t)||l(t);null!==n;)e[e.length]=n,n=i(t)||l(t);return e.length?e:null},v=function(t){var e,n,i;return e=t.pos,(n=m(t))?(-1!==(i=n.indexOf(t.delimiters[0]))&&(n=n.substr(0,i),t.pos=e+n.length),{type:T,value:n}):null},g=function(e){var n,r,o;if(n=e.pos,!t(e,"'"))return null;for(r=[],o=i(e)||v(e);null!==o;)r[r.length]=o,o=i(e)||v(e);return t(e,"'")?r:(e.pos=n,null)},b=function(t){var e,n,i;return e=t.pos,(n=y(t))?(-1!==(i=n.indexOf(t.delimiters[0]))&&(n=n.substr(0,i),t.pos=e+n.length),{type:T,value:n}):null},w=function(e){var n,r,o;if(n=e.pos,!t(e,'"'))return null;for(r=[],o=i(e)||b(e);null!==o;)r[r.length]=o,o=i(e)||b(e);return t(e,'"')?r:(e.pos=n,null)}}(),function(){s=function(t){var e,n;return e=t.str.length,[t.delimiters[0],t.tripleDelimiters[0],"<"].forEach(function(n){var i=t.str.indexOf(n,t.pos);-1!==i&&(e=Math.min(i,e))}),e===t.pos?null:(n=t.str.substring(t.pos,e),t.pos=e,{type:T,value:n})}}(),function(){var i,r,o,s,h,u,c,d,l,f,g,v,w,b,x,_,k,E,O,F,L,M,A,S,R,C,P;a=function(t){var e,n;return e=t.pos,n=f(t)},i=function(e){var r,o,s,h;if(r=e.pos,n(e),s=a(e),null===s)return null;if(o=[s],n(e),t(e,",")){if(h=i(e),null===h)return e.pos=r,null;o=o.concat(h)}return o},s=function(e){var i,r;return i=e.pos,t(e,"(")?(n(e),(r=a(e))?(n(e),t(e,")")?{t:ie,x:r}:(e.pos=i,null)):(e.pos=i,null)):null},h=function(t){return k(t)||x(t)||s(t)},u=function(t){var e,n,i;if(e=h(t),!e)return null;if(n=_(t),!n)return e;for(;null!==n;)i={t:ee,x:e,r:n},e=i,n=_(t);return i},c=function(e){var r,o,s,a;return(o=u(e))?(r=e.pos,t(e,"(")?(n(e),s=i(e),n(e),t(e,")")?(a={t:se,x:o},s&&(a.o=s),a):(e.pos=r,o)):o):null},r=function(e,i){return function(r){var o,s;return t(r,e)?(o=r.pos,n(r),expr=a(r),s||N(r,"an expression"),{s:e,o:s,t:ne}):i(r)}},function(){var t,e,n,i,o;for(i="! ~ + - typeof".split(" "),o=c,t=0,e=i.length;e>t;t+=1)n=r(i[t],o),o=n;d=o}(),o=function(e,i){return function(r){var o,s,h;return(s=i(r))?(o=r.pos,n(r),t(r,e)?(n(r),h=a(r),h?{t:oe,s:e,o:[s,h]}:(r.pos=o,s)):(r.pos=o,s)):null}},function(){var t,e,n,i,r;for(i="* / % + - << >> >>> < <= > >= in instanceof == != === !== & ^ | && ||".split(" "),r=d,t=0,e=i.length;e>t;t+=1)n=o(i[t],r),r=n;l=r}(),f=function(e){var i,r,o,s;return(r=l(e))?(i=e.pos,n(e),t(e,"?")?(n(e),(o=a(e))?(n(e),t(e,":")?(n(e),s=a(e),s?{t:re,o:[r,o,s]}:(e.pos=i,r)):(e.pos=i,r)):(e.pos=i,r)):(e.pos=i,r)):null},g=e(/^[0-9]+/),v=e(/^[eE][\-+]?[0-9]+/),w=e(/^\.[0-9]+/),b=e(/^(0|[1-9][0-9]*)/),x=function(e){var n=p(e);return null===n?t(e,".")?{t:Q,n:"."}:null:{t:Q,n:n}},_=function(e){var i,r,o;if(i=e.pos,n(e),t(e,".")){if(n(e),r=p(e))return{t:te,n:r};N("a property name")}return t(e,"[")?(n(e),o=a(e),o||N("an expression"),n(e),t(e,"]")||N('"]"'),{t:te,x:o}):null},k=function(t){var e=F(t)||O(t)||A(t)||L(t)||M(t)||E(t);return e},E=function(e){var i,r;return i=e.pos,n(e),t(e,"[")?(r=expressionList(e),t(e,"]")?{t:Z,o:r}:(e.pos=i,null)):(e.pos=i,null)},O=function(t){var e=t.remaining();return"true"===e.substr(0,4)?(t.pos+=4,{t:K,v:"true"}):"false"===e.substr(0,5)?(t.pos+=5,{t:K,v:"false"}):null},P=/^(?:Array|Date|RegExp|decodeURIComponent|decodeURI|encodeURIComponent|encodeURI|isFinite|isNaN|parseFloat|parseInt|JSON|Math|NaN|undefined|null)/,A=function(t){var e,n,i;return e=t.pos,(n=p(t))?(i=P.exec(n))?(t.pos=e+i[0].length,{t:G,v:i[0]}):(t.pos=e,null):null},F=function(t){var e,n;return e=t.pos,n=b(t),null===n?null:(n+=w(t)||"",n+=v(t)||"",{t:X,v:n})},M=function(e){var i,r;return i=e.pos,n(e),t(e,"{")?(r=S(e),n(e),t(e,"}")?{t:W,m:r}:(e.pos=i,null)):(e.pos=i,null)},S=function(e){var n,i,r,o;return n=e.pos,r=R(e),null===r?null:(i=[r],t(e,",")?(o=S(e),o?i.concat(o):(e.pos=n,null)):i)},R=function(e){var i,r,o;return i=e.pos,n(e),r=C(e),null===r?(e.pos=i,null):(n(e),t(e,":")?(n(e),o=a(e),null===o?(e.pos=i,null):{t:KEY_VALUE_PAIR,k:r,v:o}):(e.pos=i,null))},C=function(t){return p(t)||L(t)||F(t)},L=function(e){var n,i;return n=e.pos,t(e,'"')?(i=y(e),t(e,'"')?{t:J,v:i}:(e.pos=n,null)):t(e,"'")?(i=m(e),t(e,"'")?{type:J,value:i}:(e.pos=n,null)):null}}()})();var ye;ye=function(t,e){var n,i,r,o,s;return e=e||{},s=/^\s*$/,e.sanitize===!0&&(e.sanitize={elements:"applet base basefont body frame frameset head html isindex link meta noframes noscript object param script style title".split(" "),eventAttributes:!0}),n=we(t,e),e.preserveWhitespace||(o=n[0],o&&o.type===T&&s.test(o.value)&&n.shift(),o=n[n.length-1],o&&o.type===T&&s.test(o.value)&&n.pop()),i=me(n,0,e,e.preserveWhitespace),r=i.toJson(),"string"==typeof r?[r]:r};var we=function(t,e){var n,i,r,o,s;for(e=e||{},n={str:O(t),pos:0,delimiters:e.delimiters||["{{","}}"],tripleDelimiters:e.tripleDelimiters||["{{{","}}}"],remaining:function(){return n.str.substring(n.pos)}},i=[];n.pos<n.str.length;){if(r=ve(n),null===r&&n.remaining())throw o=n.str.substr(0,n.pos).substr(-20),20===o.len