(function(n,t){typeof exports=="object"&&exports&&typeof exports.nodeName!="string"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(n.Mustache={},t(n.Mustache))})(this,function(n){function f(n){return typeof n=="function"}function l(n){return u(n)?"array":typeof n}function o(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function s(n,t){return n!=null&&typeof n=="object"&&t in n}function v(n,t){return a.call(n,t)}function p(n){return!v(y,n)}function b(n){return String(n).replace(/[&<>"'`=\/]/g,function(n){return w[n]})}function tt(t,i){function lt(){if(ft&&!w)while(y.length)delete a[y.pop()];else y=[];ft=!1;w=!1}function ht(n){if(typeof n=="string"&&(n=n.split(d,2)),!u(n)||n.length!==2)throw new Error("Invalid tags: "+n);et=new RegExp(o(n[0])+"\\s*");v=new RegExp("\\s*"+o(n[1]));st=new RegExp("\\s*"+o("}"+n[1]))}var et,v,st,f,c,e,s,b,ot,l,tt,ct;if(!t)return[];var ut=[],a=[],y=[],ft=!1,w=!1;for(ht(i||n.tags),f=new r(t);!f.eos();){if(c=f.pos,s=f.scanUntil(et),s)for(tt=0,ct=s.length;tt<ct;++tt)b=s.charAt(tt),p(b)?y.push(a.length):w=!0,a.push(["text",b,c,c+1]),c+=1,b==="\n"&&lt();if(!f.scan(et))break;if(ft=!0,e=f.scan(nt)||"name",f.scan(k),e==="="?(s=f.scanUntil(h),f.scan(h),f.scanUntil(v)):e==="{"?(s=f.scanUntil(st),f.scan(g),f.scanUntil(v),e="&"):s=f.scanUntil(v),!f.scan(v))throw new Error("Unclosed tag at "+f.pos);if(ot=[e,s,c,f.pos],a.push(ot),e==="#"||e==="^")ut.push(ot);else if(e==="/"){if(l=ut.pop(),!l)throw new Error('Unopened section "'+s+'" at '+c);if(l[1]!==s)throw new Error('Unclosed section "'+l[1]+'" at '+c);}else e==="name"||e==="{"||e==="&"?w=!0:e==="="&&ht(s)}if(l=ut.pop(),l)throw new Error('Unclosed section "'+l[1]+'" at '+f.pos);return rt(it(a))}function it(n){for(var u=[],t,i,r=0,f=n.length;r<f;++r)t=n[r],t&&(t[0]==="text"&&i&&i[0]==="text"?(i[1]+=t[1],i[3]=t[3]):(u.push(t),i=t));return u}function rt(n){for(var u=[],r=u,i=[],t,e,f=0,o=n.length;f<o;++f){t=n[f];switch(t[0]){case"#":case"^":r.push(t);i.push(t);r=t[4]=[];break;case"/":e=i.pop();e[5]=t[2];r=i.length>0?i[i.length-1][4]:u;break;default:r.push(t)}}return u}function r(n){this.string=n;this.tail=n;this.pos=0}function i(n,t){this.view=n;this.cache={".":this.view};this.parent=t}function t(){this.cache={}}var c=Object.prototype.toString,u=Array.isArray||function(n){return c.call(n)==="[object Array]"},a=RegExp.prototype.test,y=/\S/,w={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},k=/\s*/,d=/\s+/,h=/\s*=/,g=/\s*\}/,nt=/#|\^|\/|>|\{|&|=|!/,e;return r.prototype.eos=function(){return this.tail===""},r.prototype.scan=function(n){var i=this.tail.match(n),t;return!i||i.index!==0?"":(t=i[0],this.tail=this.tail.substring(t.length),this.pos+=t.length,t)},r.prototype.scanUntil=function(n){var i=this.tail.search(n),t;switch(i){case-1:t=this.tail;this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,i);this.tail=this.tail.substring(i)}return this.pos+=t.length,t},i.prototype.push=function(n){return new i(n,this)},i.prototype.lookup=function(n){var o=this.cache,t,i,r,u,e;if(o.hasOwnProperty(n))t=o[n];else{for(i=this,e=!1;i;){if(n.indexOf(".")>0)for(t=i.view,r=n.split("."),u=0;t!=null&&u<r.length;)u===r.length-1&&(e=s(t,r[u])),t=t[r[u++]];else t=i.view[n],e=s(i.view,n);if(e)break;i=i.parent}o[n]=t}return f(t)&&(t=t.call(this.view)),t},t.prototype.clearCache=function(){this.cache={}},t.prototype.parse=function(n,t){var r=this.cache,i=r[n];return i==null&&(i=r[n]=tt(n,t)),i},t.prototype.render=function(n,t,r){var u=this.parse(n),f=t instanceof i?t:new i(t);return this.renderTokens(u,f,r,n)},t.prototype.renderTokens=function(n,t,i,r){for(var s="",f,e,u,o=0,h=n.length;o<h;++o)u=undefined,f=n[o],e=f[0],e==="#"?u=this.renderSection(f,t,i,r):e==="^"?u=this.renderInverted(f,t,i,r):e===">"?u=this.renderPartial(f,t,i,r):e==="&"?u=this.unescapedValue(f,t):e==="name"?u=this.escapedValue(f,t):e==="text"&&(u=this.rawValue(f)),u!==undefined&&(s+=u);return s},t.prototype.renderSection=function(n,t,i,r){function l(n){return c.render(n,t,i)}var c=this,o="",e=t.lookup(n[1]),s,h;if(e){if(u(e))for(s=0,h=e.length;s<h;++s)o+=this.renderTokens(n[4],t.push(e[s]),i,r);else if(typeof e=="object"||typeof e=="string"||typeof e=="number")o+=this.renderTokens(n[4],t.push(e),i,r);else if(f(e)){if(typeof r!="string")throw new Error("Cannot use higher-order sections without the original template");e=e.call(t.view,r.slice(n[3],n[5]),l);e!=null&&(o+=e)}else o+=this.renderTokens(n[4],t,i,r);return o}},t.prototype.renderInverted=function(n,t,i,r){var f=t.lookup(n[1]);if(!f||u(f)&&f.length===0)return this.renderTokens(n[4],t,i,r)},t.prototype.renderPartial=function(n,t,i){if(i){var r=f(i)?i(n[1]):i[n[1]];if(r!=null)return this.renderTokens(this.parse(r),t,i,r)}},t.prototype.unescapedValue=function(n,t){var i=t.lookup(n[1]);if(i!=null)return i},t.prototype.escapedValue=function(t,i){var r=i.lookup(t[1]);if(r!=null)return n.escape(r)},t.prototype.rawValue=function(n){return n[1]},n.name="mustache.js",n.version="2.3.0",n.tags=["{{","}}"],e=new t,n.clearCache=function(){return e.clearCache()},n.parse=function(n,t){return e.parse(n,t)},n.render=function(n,t,i){if(typeof n!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+l(n)+'" was given as the first argument for mustache#render(template, view, partials)');return e.render(n,t,i)},n.to_html=function(t,i,r,u){var e=n.render(t,i,r);if(f(u))u(e);else return e},n.escape=b,n.Scanner=r,n.Context=i,n.Writer=t,n})