text: /* grips (c) 2012-2014 Kyle Simpson | http://getify.mit-license.org/ */
  ;(function(){Object.keys||(Object.keys=function(t){var n,r=[];for(n in t)t.hasOwnProperty(n)&&r.push(n);return r}),Array.isArray||(Array.isArray=function(t){return Object.prototype.toString(t)==="[object Array]"}),function(t){function r(){function e(){}function i(){var e=t.grips;return t.grips=n,e}function s(e){e in g||(g[e]={collection:"",extend:null,partials:{}})}function o(e,t){s(e),g[e].extend=t}function u(t){var n,r,i;if(typeof t=="object"){if(t===null)return t;if(Array.isArray(t)){r=[];for(n=0;n<t.length;n++)typeof t[n]=="object"?i=u(t[n]):i=t[n],r.push(i)}else{t instanceof e?r=new e:r={};for(n in t)t.hasOwnProperty(n)&&(typeof (t[n]==="object")?i=u(t[n]):i=t[n],r[n]=i)}}else r=t;return r}function a(e,t){var n=t.match(/^(.+)#/);n&&(n=n[1]);if(!n)throw y;s(n),g[n].partials[t.replace(/^.*#/,"#")]=function(n,r){var i;try{i=e(n,r)}catch(s){throw y}if(i instanceof Error)throw i;return i}}function f(e,t){var n="",r,i;t=t!==!1;if(Array.isArray(e))for(r=0;r<e.length;r++)n+=c(e[r],null,t);else if(typeof e=="object")for(i in e)e.hasOwnProperty(i)&&(n+=c(e[i],i,t));return n}function l(e,t){if(!t)throw y;return c(e,t,!1)}function c(e,t,n){n=n!==!1;try{if(m.tokenizer.process(e,t))return m.parser.end(),m.generator.process(n)}catch(r){throw y}return!1}function h(e){var n=new Function(e);n.call(t)}function p(e,t){s(e),h(t)}function d(e,t,n){if(!e)return"";t=t||{},n=n||{};var r,i=!1,s,o,u=[],a=!1,f=!1;r=e.match(/^(.+)#/),r&&(r=r[1],a=!0);if(!a&&b.length>0)r=b[b.length-1];else if(!a||b.length>0&&b[b.length-1]===r){if(!r)throw y}else b.push(r),f=!0;if(r in g){e=e.replace(/^(.+)#/,"#"),o=r+e,w.push(o);for(s=0;s<w.length-1;s++)if(w[s]===o)throw y;a?u.push(r):u=u.concat(b);if(!(e in g[r].partials)&&g[r].extend){o=g[r].extend;while(o&&o in g)u.push(o),o=g[o].extend}for(s=0;s<u.length;s++)if(e in g[u[s]].partials){i=g[u[s]].partials[e](t,n);break}}if(i!==!1)return w.pop(),f&&b.pop(),i;throw y}function v(e,t){return typeof e=="string"&&(t.html&&/[&<>"]/.test(e)&&(e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")),t.string&&(e=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\t/g,"\\t")),t.url&&(e=encodeURIComponent(e))),e}var m,g={},y=new Error("Unknown error"),b=[],w=[];return m={extend:o,cloneObj:u,definePartial:a,strEscapes:v,compile:f,compileChunk:l,compileCollection:c,initialize:h,initializeCollection:p,render:d,noConflict:i,sandbox:r,RangeLiteralHash:e,collections:g},m}var n=t.grips;t.grips=r()}(this),function(t,n){function r(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}function i(){var e;do e=Math.floor(Math.random()*1e9);while(e in u);return e}function s(e,t){function s(e){var t,n,r,i;for(r=0;r<e.length;r++)if(e[r].type===E){t=n=r;for(i=t+1;i<e.length;i++){n=i;if(e[i].type!==E){n=i-1;break}}if(n>t){for(i=t+1;i<=n;i++)e[t].val+=e[i].val;e.splice(t+1,n-t)}else r=i}return e}function g(e){for(var t=0;t<e.length;t++)e[t].type===E&&(e[t].val=e[t].val.replace(/\\\\/g,"\\"));return e}function k(){var i,u;F&&(q=new r({type:null,val:F}),/^\s+$/.test(F)?q.type=S:q.type=E,o.push(q));if(B){u=e.substring(0,D-B[0].length);if(!!u&&!T.test(u)){o.push(new r({type:E,val:B[0]}));return}if(B[0]==="{$}")o.push(new r({type:c,val:B[0]}));else{if(B[0]!=="{$")return C;q=new r({type:a,val:B[0]}),o.push(q);if(!(D<e.length-1&&(B=e.substr(D).match(/^(?:(?:~|escape\s+)[hsuHSU]+|[~:+=*\/%#]|(?:(?:define|extend|insert|print|partial|loop|let|comment|raw|escape)\b))/))))return C;o.push(new r({type:h,val:B[0]})),D+=B[0].length}}o=o.concat(i=g(s(o.splice(H-o.length)))),I=n.parser.nodify(i,t),H=o.length}function L(){var e,i;if(F){if(i=F.match(/[^a-z0-9_$\s]/i))return C;o.push(new r({type:E,val:F}))}if(B)if(B[0]==="$}")o.push(new r({type:f,val:B[0]}));else if(B[0]==="}")o.push(new r({type:l,val:B[0]}));else{if(/^\s+$/.test(B[0])){o.push(new r({type:S,val:B[0]}));return}if(/^["']$/.test(B[0]))q=new r({type:0,val:B[0]}),B[0]==='"'?q.type=b:q.type=y,o.push(q),N[n.parser.LITERAL]=new RegExp(B[0],"g"),N[n.parser.LITERAL].lastIndex=0;else if(/^(?:\.\.)|[:=?\(\)\[\],\-.!]$/.test(B[0]))o.push(new r({type:w,val:B[0]}));else if(B[0]==="|")o.push(new r({type:v,val:B[0]}));else if(B[0]==="@")o.push(new r({type:m,val:B[0]}));else{if(!/^~[hsuHSU]*$/.test(B[0])){o.push(new r({type:E,val:B[0]}));return}o.push(new r({type:x,val:B[0]}))}}o=o.concat(e=g(s(o.splice(H-o.length)))),I=n.parser.nodify(e,t),H=o.length}function A(){var e,i;o[o.length-1].type!==E&&o.push(new r({type:E,val:""})),F&&(o[o.length-1].val+=F),B&&(i=o[o.length-1].val,!i||T.test(i)?(o.push(new r({type:d,val:B[0]})),o=o.concat(e=g(s(o.splice(H-o.length)))),I=n.parser.nodify(e,t),H=o.length):(i&&!T.test(i)&&(o[o.length-1].val=o[o.length-1].val.substr(0,o[o.length-1].val.length-1)),o[o.length-1].val+=B[0]))}function O(){var e,i;if(B){i=o[o.length-1].val;if(!i||T.test(i))o.push(new r({type:p,val:B[0]})),o=o.concat(e=g(s(o.splice(H-o.length)))),I=n.parser.nodify(e,t),H=o.length}}function M(){var e,i;o[o.length-1].type!==E&&o.push(new r({type:E,val:""})),F&&(o[o.length-1].val+=F),B&&(i=o[o.length-1].val,!i||T.test(i)?(o.push(new r({type:B[0]==='"'?b:y,val:B[0]})),o=o.concat(e=g(s(o.splice(H-o.length)))),I=n.parser.nodify(e,t),H=o.length,N[n.parser.STRING_LITERAL]=null):(i&&!T.test(i)&&(o[o.length-1].val=o[o.length-1].val.substr(0,o[o.length-1].val.length-1)),o[o.length-1].val+=B[0]))}var _,D=0,P=0,H=o.length,B,j,F,I,q,R,U=[k,L,A,O,M];t||(t=i(),u[t]=!0,t="chunk_"+t);while((!I||I===!0)&&D<e.length){F="",I=null,j=n.parser.state;if(j===n.parser.INVALID)break;_=N[j];if(!_){I=C;break}_.lastIndex=D,B=_.exec(e);if(B)P=D,D=_.lastIndex,P<D-B[0].length&&(F=e.substring(P,D-B[0].length));else{P=D,D=e.length,F=e.substr(P);if(!F)break}R=U[j]();if(R&&R!==!0)break;if(I&&I!==!0)break}if(R instanceof Error)throw R;if(I instanceof Error)throw I;return!0}var o=[],u={},a=0,f=1,l=2,c=3,h=4,p=5,d=6,v=7,m=8,g=9,y=10,b=11,w=12,E=13,S=14,x=15,T=/(?:[^\\]|(?:^|[^\\])(?:\\\\)+)$/,N=[/\{\$\}|\{\$/g,/\$\}|\}|(?:\.\.)|(?:~[hsuHSU]*)|["':=@\|?\(\)\[\],\-.!#]|\s+/g,/%\$\}/g,/\/\$\}/g],C=new Error("Unknown error");n.tokenizer={OPEN:a,SIMPLE_CLOSE:f,BLOCK_HEAD_CLOSE:l,BLOCK_FOOTER:c,SIGNIFIER:h,COMMENT_CLOSE:p,RAW_CLOSE:d,PIPE:v,AT:m,STRING_LITERAL:g,SINGLE_QUOTE:y,DOUBLE_QUOTE:b,OPERATOR:w,GENERAL:E,WHITESPACE:S,TILDE:x,process:s,Token:r}}(this,this.grips),function(t,n){function r(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}function i(e,t){function i(e){if(e.type===n.tokenizer.OPEN)l=new r({parent:null,type:null,token:e,def:[],children:[],complete:!1}),d?(l.parent=d,d.children.push(l)):(delete l.parent,p.push(l)),d=l,$.state=y;else if(e.type===n.tokenizer.GENERAL)l=new r({parent:null,type:x,token:e,val:e.val,complete:!0}),d?(l.parent=d,d.children.push(l)):(delete l.parent,p.push(l));else if(d&&e.type===n.tokenizer.WHITESPACE)l=new r({parent:d,type:x,token:e,val:e.val,complete:!0}),d.children.push(l);else if(e.type===n.tokenizer.BLOCK_FOOTER){if(!d||d.close_header!==n.tokenizer.BLOCK_HEAD_CLOSE)return $.state=S,J;d.complete=!0,d=d.parent}}function s(e){function i(){if(d.type===k||d.type===C||d.type===L||d.type===V){l=new r({parent:d,type:null,token:null,def:[]});if(!d.main_expr&&d.type===L)d.main_expr=l,l.type=_;else if(d.type===k||d.type===C){if(!!d.main_expr)return $.state=S,J;d.main_expr=l,l.type=_,d.type===C&&(l.collection_id=t)}else l.type=D;d.def.push(l),d=l}}if(e.type===n.tokenizer.SIGNIFIER){if(!d||d.type!=null)return $.state=S,J;/^(?:\:|define)$/.test(e.val)?d.type=N:/^(?:\+|extend)$/.test(e.val)?d.type=T:/^(?:\=|insert|print)$/.test(e.val)?d.type=k:/^partial$/.test(e.val)?d.type=C:/^(?:\*|loop)$/.test(e.val)?d.type=L:/^(?:#|let)$/.test(e.val)?d.type=V:/^(?:\%|raw)$/.test(e.val)?d.type=A:/^(?:\/|comment)$/.test(e.val)?d.type=O:/^(?:escape|(?:~|escape\s+)[hsuHSU]*)$/.test(e.val)&&(d.type=X),d.type===T||d.type===k?(d.close_header=n.tokenizer.SIMPLE_CLOSE,delete d.children):d.type===C?d.close_header=n.tokenizer.SIMPLE_CLOSE:d.type===N||d.type===L||d.type===V?d.close_header=n.tokenizer.BLOCK_HEAD_CLOSE:d.type===X?(d.close_header=n.tokenizer.BLOCK_HEAD_CLOSE,d.escapes={},/(?:~.*|escape\s+.*)h/i.test(e.val)&&(d.escapes.html=!0),/(?:~.*|escape\s+.*)s/i.test(e.val)&&(d.escapes.string=!0),/(?:~.*|escape\s+.*)u/i.test(e.val)&&(d.escapes.url=!0),/\b[hsu]$/i.test(e.val)||(d.escapes.string=!0),delete d.def):d.type===A?(d.val="",$.state=b,delete d.def,delete d.children):d.type===O&&(d.val="",$.state=w,delete d.def,delete d.children);if(!d.parent&&d.type!==T&&d.type!==N&&d.type!==O||d.parent&&(d.type===T||d.type===N))return $.state=S,J}else if(e.type===n.tokenizer.WHITESPACE){if(d){if(d.type!==T&&d.type!==N&&d.type!==C&&d.type!==k&&d.type!==L&&d.type!==V&&d.type!==X&&d.type!==D&&d.type!==_)return $.state=S,J;d.def&&d.def.length>0&&d.def.push(new r({parent:d,type:U,token:e}))}}else if(e.type===n.tokenizer.AT){if(!d||d.type!==k||d.def.length!==0)return $.state=S,J;d.type=C}else if(e.type===n.tokenizer.TILDE){if(!d||d.type!==C&&d.type!==k||d.def.length!==0)return $.state=S,J;d.escapes={},/h/i.test(e.val)&&(d.escapes.html=!0),/s/i.test(e.val)&&(d.escapes.string=!0),/u/i.test(e.val)&&(d.escapes.url=!0),/[hsu]/i.test(e.val)||(d.escapes.string=!0)}else if(e.type===n.tokenizer.SINGLE_QUOTE||e.type===n.tokenizer.DOUBLE_QUOTE){if(!d||d.type!==T&&d.type!==N&&d.type!==C&&d.type!==D&&d.type!==_)return $.state=S,J;$.state=E,l=new r({parent:d,type:null,token:e,val:"",delimiter:e.val});if(d.type===N||d.type===T){if(!!d.id)return $.state=S,J;d.id=l,l.type=M,d.type===N&&(l.collection_id=t)}else if(d.type===C){if(!!d.main_expr)return $.state=S,J;d.main_expr=l,l.type=M,l.collection_id=t}else l.type=I;d.def.push(l),d=l}else if(e.type===n.tokenizer.OPERATOR){if(!d)return $.state=S,J;/[\(\[]/.test(e.val)&&i();if(d.type!==D&&d.type!==_)return $.state=S,J;d.token||(d.token=e);if(e.val==="-"&&d.def.length>0&&d.def[d.def.length-1].type!==U&&(d.def[d.def.length-1].type!==z||!/(?:\.\.)|\[/.test(d.def[d.def.length-1].val)))return J;d.def.push(new r({parent:d,type:z,token:e,val:e.val}))}else if(e.type===n.tokenizer.PIPE){if(!d)return $.state=S,J;if(d.type===D||d.type===_){if(d.def.length===0)return $.state=S,J;d=d.parent}if(d.type===V&&d.def.length===0)return $.state=S,J;if(!d.id&&(d.type===N||d.type===T))return $.state=S,J;if(!(d.type===N||d.type===L||d.type===V||d.type===C&&!d.context_expr))return $.state=S,J;l=new r({parent:d,type:D,token:null,def:[]}),d.type===C&&(d.context_expr=l),d.def.push(l),d=l}else if(e.type===n.tokenizer.SIMPLE_CLOSE){if(!d)return $.state=S,J;if(d.type===D||d.type===_)d=d.parent;if(!d.id&&d.type===T)return $.state=S,J;if(d.close_header!==n.tokenizer.SIMPLE_CLOSE)return $.state=S,J;d.type===C&&!d.context_expr&&(l=new r({parent:d,type:D,token:null,def:[]}),l.def.push(new r({parent:l,type:x,token:null,val:"$"})),d.context_expr=l,d.def.push(l)),d.complete=!0,$.state=g,d=d.parent}else if(e.type===n.tokenizer.BLOCK_HEAD_CLOSE){if(!d)return $.state=S,J;if(d.type===D||d.type===_)d=d.parent;if(d.type===V&&d.def.length===0)return $.state=S,J;if(!d.id&&d.type===N)return $.state=S,J;if(d.close_header!==n.tokenizer.BLOCK_HEAD_CLOSE)return $.state=S,J;$.state=g}else if(e.type===n.tokenizer.GENERAL){if(!d)return $.state=S,J;i();if(d.type!==D&&d.type!==_)return $.state=S,J;d.token||(d.token=e),/^\d+$/.test(e.val)&&d.def.length>0&&d.def[d.def.length-1].type===z&&d.def[d.def.length-1].val==="-"?d.def[d.def.length-1]=new r({parent:d,type:x,token:new n.tokenizer.Token({type:n.tokenizer.GENERAL,val:"-"+e.val}),val:"-"+e.val}):d.def.push(new r({parent:d,type:x,token:e,val:e.val}))}}function o(e){if(e.type===n.tokenizer.GENERAL)d.token.type!==n.tokenizer.GENERAL&&(d.token=e),d.val+=e.val;else{if(e.type!==n.tokenizer.RAW_CLOSE)return J;d.complete=!0,d=d.parent,$.state=g}}function u(e){e.type===n.tokenizer.COMMENT_CLOSE&&(d=d.parent,d?d.children.pop():p.pop(),$.state=g)}function a(e){if(e.type===n.tokenizer.GENERAL)d.token.type!==n.tokenizer.GENERAL&&(d.token=e),d.val+=e.val;else{if(e.type!==n.tokenizer.SINGLE_QUOTE&&e.type!==n.tokenizer.DOUBLE_QUOTE||d.delimiter!==e.val)return J;d=d.parent,$.state=y}}var f,l,c,h=[i,s,o,u,a];t!==v&&(v&&p.push(new r({type:W,close:v,complete:!0})),v=t,p.push(new r({type:W,start:t,complete:!0})));for(f=0;f<e.length;f++){if($.state===S)return J;c=h[$.state](e[f]);if(c)return c}return!0}function s(){v&&p.push(new r({type:W,close:v,complete:!0})),v=null}function o(e){var t,n,r,i;for(r=0;r<e.length;r++)if(e[r].type===x){t=n=r;for(i=t+1;i<e.length;i++){n=i;if(e[i].type!==x){n--;break}}if(n>t){for(i=t+1;i<=n;i++)e[t].token.val+=e[i].token.val,e[t].val+=e[i].val;e.splice(t+1,n-t)}else r=i}return u(e)}function u(e){var t,n,r,i;for(r=0;r<e.length;r++)if(e[r].type===U){t=n=r;for(i=t+1;i<e.length;i++){n=i;if(e[i].type!==U){n--;break}}if(n>t){for(i=t+1;i<=n;i++)e[t].token.val+=e[i].token.val,e[t].val+=e[i].val;e.splice(t+1,n-t)}else r=i}return e}function a(e){var t=[],n=0,r=e.length-1;while(n<=r){e[n].type===U&&n++,e[r].type===U&&r--;if(!(n<r)||e[n].type!==U&&e[r].type!==U)break}return n<=r&&(t=e.slice(n,r+1)),t}function f(e){var t=[],n=0,r=e.length-1,i,s=0;while(n<r){e[n].type===U&&n++,e[r].type===U&&r--;if(n<r&&e[n].type!==U&&e[r].type!==U){if(e[n].type!==z||e[n].val!=="("||e[r].type!==z||e[r].val!==")")break;for(i=n+1;i<r;i++)if(e[i].type===z){e[i].val==="("?s++:e[i].val===")"&&s--;if(s<0)break}if(s!==0)break;n++,r--}}return n<=r&&(t=e.slice(n,r+1)),t}function l(e){for(var t=0;t<e.length;t++)e[t].type===z&&(e.splice(t,1),t--)}function c(e){function t(e){var t,n,r=[],i=!1;if(e.length<5)return!1;if(e[0].type!==z||e[0].val!=="[")return!1;r.push(e[0]);for(t=1;t<e.length;t++){n=e[t];if(n.type===U)continue;r.push(n);if(n.type===z){if(n.val==="]")break;if(!/(?:\.\.)|[\-,]/.test(n.val))return!1;/(?:\.\.)|,/.test(n.val)&&(i=!0)}}return r.length<5||!i?!1:r}function i(e){function t(e,t,n){var i,s;e=f(e),i=new r({parent:u,type:t,token:e[0].token,def:e}),S=n(i);if(S)return S;for(s=0;s<i.def.length;s++)i.def[s].parent=i;return i}var n,i,s=[],o,u,a,l,c;if(e.length>0){for(n=0;n<e.length;n++){i=e[n];if(i.type===z&&/[?:]/.test(i.val)){if(i.val==="?"){if(!!u)return!1;u=new r({parent:null,type:j,token:e[0].token,def:[]}),a=t(s,F,h);if(a instanceof Error)throw a;c=new r({parent:u,type:B,token:null,def:[]}),o=new r({parent:c,type:I,token:null,val:"",delimiter:'"'}),c.def.push(o),s=[]}else if(i.val===":"){if(!u||!!l)return!1;l=t(s,B,g);if(l instanceof Error)throw l;s=[]}}else s.push(i)}if(s.length>0){if(!u)return!1;if(!l){l=t(s,B,g);if(l instanceof Error)throw l}else{c=t(s,B,g);if(c instanceof Error)throw c}s=[]}if(a&&l)return u.def.push(a,l,c),u}}function s(e){var t;if((t=e.val.match(/#/g))&&t.length>1)return J;if(e.parent.type===N){if(!e.val)return J;if(!/^#/.test(e.val))return J;if(!/^#[a-z0-9_\-$.+=\/]/i.test(e.val))return J;if(t=e.val.match(/(#.*?)([^a-z0-9_\-$.+=\/]).*$/i))return J;e.val=e.collection_id+e.val}else if(e.parent.type===T){if(t=e.val.match(/#/))return J}else if(e.parent.type===C){if(!e.val||!/#.+/.test(e.val))return J;if(t=e.val.match(/(#.*?)([^a-z0-9_\-$.+=\/]).*$/i))return J}}function h(e){function t(e){while(e.parent&&(e=e.parent))if(e.type===n.parser.TAG_LOOP)return!0;return!1}function r(e){while(e.parent&&(e=e.parent))if(e.type===n.parser.MAIN_REF_EXPR||e.type===n.parser.ASSIGNMENT_EXPR)return e.type===n.parser.MAIN_REF_EXPR;return!1}var i,s,o,u,a=[];if(!(e.def&&e.def.length>0))return J;for(i=0;i<e.def.length;i++){if(e.def[i].type===U)continue;o=u,u=e.def[i];if(u.type===z){if(!/[.!\[\]\(\)]/.test(u.val))return J;if(i===e.def.length-1&&!/[\]\)]/.test(u.val))return J;if(o)if(o.type===z){if(u.val==="("&&!/[!\(\[]/.test(o.val))return J;if(u.val==="!"&&!/[!\(]/.test(o.val))return J;if(/[.\[\]\)]/.test(u.val)&&!/[\]\)]/.test(o.val))return J}else{if(o.type===x&&!/[.\[\]\)]/.test(u.val))return J;if(o.type===I&&!/[\]\)]/.test(u.val))return J}else if(!/[!\(]/.test(u.val))return J;if(/[\[\(]/.test(u.val))a.push(u.val);else if(/[\]\)]/.test(u.val)){if(!(a.length>0&&(a[a.length-1]==="["&&u.val==="]"||a[a.length-1]==="("&&u.val===")")))return J;a.pop()}}else if(u.type===x){if(/^\d/.test(u.val)){if(!/^\d+$/.test(u.val))return J;if(o&&(o.type!==z||!/[\(\[]/.test(o.val)))return J}s=r(u);if(e.def.length===1&&u.val==="_"&&!s&&u.parent.parent.context_expr!==u.parent)return J;if(u.val==="_"&&!(s&&t(u.parent.parent)||!s&&t(u)))return J;if(o){if(o.type===x)return J;if(o.type===z&&!/[.!\(\[]/.test(o.val))return J}}else if(u.type===I&&o&&(o.type!==z||!/[\[\(]/.test(o.val)))return J}if(a.length>0)return J}function p(e){if(!e.def||e.def.length!==5)return J;if(e.def[1].type!==x||!/^-?\d+$/.test(e.def[1].val))return J;if(e.def[3].type!==x||!/^-?\d+$/.test(e.def[3].val))return J;if(e.def[2].type!==z||e.def[2].val!=="..")return J}function d(e){var t,n,r;if(!(e.def&&e.def.length>=5))return J;for(t=1;t<e.def.length-1;t++){n=r,r=e.def[t];if(r.type===I){if(n&&(n.type!==z||n.val!==","))return J}else{if(r.type!==z||r.val!==",")return J;if(!n||n.type!==I)return J}}if(e.def[e.def.length-2].type!==I)return J}function m(e){var n,s,o,u,c,h,v=[],m,b;if(!(e.def&&e.def.length>0))return J;for(n=0;n<e.def.length;n++){if(e.def[n].type===U)continue;o=u,u=e.def[n];if(!!m){c=f(e.def.slice(n));if(c.length===0)return J;b=new r({parent:e,type:B,token:c[0].token,def:[]}),h=i(c);if(!h){b.def=c,S=g(b);if(S)return S}else b.def=[h];for(s=0;s<b.def.length;s++)b.def[s].parent=b;break}if(u.type===z)if(u.val==="="){m=new r({parent:e,type:H,token:v[0].token,def:v});if(!v[0]||v[0].type!==H||!v[1]||v[1].type!==R&&v[1].type!==q){S=y(m);if(S)return S}for(s=0;s<m.def.length;s++)m.def[s].parent=m;v=[]}else if(u.val==="["){c=t(e.def.slice(n));if(c){h=new r({parent:null,type:H,token:e.def[0].token,def:e.def.slice(0,n)}),S=y(h),S||(v=[h],h=new r({parent:null,type:q,token:u.token,def:c}),S=p(h),S&&(h.type=R,S=d(h)),S?S=J:(v.push(h),n+=c.length-1,l(h.def)));if(S)return S}else v.push(u)}else{if(!o||!/[.\[\]]/.test(u.val))return J;v.push(u)}else v.push(u)}if(!m||!b)return J;m.def=a(m.def),b.def=a(b.def),e.def=[m,b],e.type=P}function g(e){var t,n,r,i=!1;if(!(e.def&&e.def.length>0))return J;for(t=0;t<e.def.length;t++){n=e.def[t];if(n.type===z){if(n.val==="!")return J}else if(n.type===x)if(!/^\d+$/.test(n.val))i=!0;else if(!i)return J}r=h(e);if(r)return r}function y(e){var t,n,r,i;if(!(e.def&&e.def.length>0))return J;for(t=0;t<e.def.length;t++){if(e.def[t].type===U)continue;n=r,r=e.def[t];if(r.type===I&&(!n||n.type!==z||n.val!=="["))return J}i=g(e);if(i)return i}var b,w,E,S,O;if(e.type===T){if(!e.id||!(b=c(e.id)))throw J;e.id=b;if(e.def&&e.def.length>0){e.def[0]=e.id;if(e.def.length>1){for(O=1;O<e.def.length;O++)if(e.def[O].type!==U)throw J;e.def=[e.id]}}return e}if(e.type===N){if(!e.id||!(b=c(e.id)))throw J;e.id=b;if(e.def&&e.def.length>0){b=[e.id],E=a(e.def.slice(1));for(O=0;O<E.length;O++)w=c(E[O]),w&&b.push(w);e.def=b}if(e.children&&e.children.length>0){e.children=o(e.children),b=[];for(O=0;O<e.children.length;O++)w=c(e.children[O]),w&&b.push(w);e.children=o(b)}return e}if(e.type===L){if(!e.main_expr||!(b=c(e.main_expr)))throw J;e.main_expr=b;if(e.def&&e.def.length>0){b=[e.main_expr],E=a(e.def.slice(1));for(O=0;O<E.length;O++)w=c(E[O]),w&&b.push(w);e.def=b}if(e.children&&e.children.length>0){e.children=o(e.children),b=[];for(O=0;O<e.children.length;O++)w=c(e.children[O]),w&&b.push(w);e.children=o(b)}return e}if(e.type===V){if(!(e.def&&e.def.length>0))throw J;b=a(e.def);for(O=0;O<b.length;O++)w=c(b[O]),w&&(b[O]=w);e.def=b;if(e.children&&e.children.length>0){e.children=o(e.children),b=[];for(O=0;O<e.children.length;O++)w=c(e.children[O]),w&&b.push(w);e.children=o(b)}return e}if(e.type===k){if(!e.main_expr||!(b=c(e.main_expr)))throw J;e.main_expr=b;if(e.def&&e.def.length>0){if(e.def.length>1)for(O=1;O<e.def.length;O++)if(e.def[O].type!==U)throw J;e.def=[e.main_expr]}return e}if(e.type===C){if(!e.main_expr||!(b=c(e.main_expr)))throw J;e.main_expr=b,e.context_expr.type=H,e.context_expr.def=a(e.context_expr.def),S=g(e.context_expr);if(S)throw S;return e.def=[e.main_expr,e.context_expr],e}if(e.type===A)return e.type=x,e;if(e.type===M){if(S=s(e))throw S;return e}if(e.type===D){if(!(e.def&&e.def.length>0))throw J;e.def=u(e.def),e.def=a(e.def),S=m(e);if(S)throw S;return e}if(e.type===_){if(!(e.def&&e.def.length>0))throw J;b=[];for(O=0;O<e.def.length;O++)e.def[O].type!==U&&b.push(e.def[O]);e.def=f(b);if((b=t(e.def))&&b.length===e.def.length){b=new r({parent:e,type:null,token:e.token,def:b});for(O=0;O<b.def.length;O++)b.def[O].parent=b;S=p(e),S?(S=d(e),S||(b.type=R)):b.type=q;if(S)throw J;l(b.def),e.def=[b]}else e.parent.type===k||e.parent.type===L?S=y(e):e.parent.type===C&&(S=g(e));if(S)throw S;return e}if(e.type!==x)return e.type===W?(e.start?v=e.start:e.close&&(v=null),e):e;if(!e.parent&&e.token.type!==n.tokenizer.WHITESPACE)throw J;if(e.val!=="")return e}function h(){var e;while(m<p.length&&!e&&p[m].complete)e=c(p[m++]);return e}var p=[],d,v="",m=0,g=0,y=1,b=2,w=3,E=4,S=5,x=0,T=1,N=2,C=3,k=4,L=5,A=6,O=7,M=8,_=9,D=10,P=11,H=12,B=13,j=14,F=15,I=16,q=17,R=18,U=19,z=20,W=21,X=22,V=23,$,J=new Error("Unknown error");$={OUTSIDE:g,INSIDE:y,RAW:b,COMMENT:w,LITERAL:E,INVALID:S,TEXT:x,TAG_EXTEND:T,TAG_DEFINE:N,TAG_INCL_TMPL:C,TAG_INSERT_VAR:k,TAG_LOOP:L,TAG_RAW:A,TAG_COMMENT:O,ID:M,MAIN_REF_EXPR:_,GENERAL_EXPR:D,ASSIGNMENT_EXPR:P,REF_EXPR:H,VAL_EXPR:B,CONDITIONAL_EXPR:j,BOOLEAN_EXPR:F,STRING_LITERAL:I,RANGE_LITERAL:q,SET_LITERAL:R,WHITESPACE:U,OPERATOR:z,COLLECTION_MARKER:W,TAG_ESCAPE:X,TAG_LET:V,state:g,nodify:i,end:s,parseNextNode:h,Node:r},n.parser=$}(this,this.grips),function(t,n){function r(e){return e.replace(/\\([\s\S])|(")/g,"\\$1$2")}function i(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function s(e){return e.replace(/\\(?!\\*\")/g,"\\\\")}function o(){var e="";return L.sort&&(e+="function __sort_fn__(a,b){ return a-b; }"),e+="var partial = G.definePartial, clone = G.cloneObj",L.extend&&(e+=", extend = G.extend"),L.esc&&(e+=", esc = G.strEscapes"),L.unerr&&(e+=', unerr = new Error("Unknown error")'),L.RLH&&(e+=", RLH = G.RangeLiteralHash"),L.cID&&(e+=', cID = "'+L.cID_value+'"'),e+=";",e}function u(e){var t="";return t+="(function(G){",t+="/*startCollection*/",t}function a(){return"})(this.grips||grips);"}function f(e){return p(e.def[0])+" ? "+p(e.def[1])+" : "+p(e.def[2])}function l(e){return e.delimiter+e.val+e.delimiter}function c(e){var t="";return t+="for (i="+e.def[0].val+"; i",e.def[0].val<=e.def[1].val?t+="<="+e.def[1].val+"; i++) {":t+=">="+e.def[1].val+"; i--) {",t}function h(e){var t,n="",r,i;i="";for(t=0;t<e.def.length;t++)r=e.def[t],i+=(i!==""?",":"")+l(r);return n+="var _set = ["+i+"];",n+="for (i=0; i<"+e.def.length+"; i++) {",n}function p(e){var t,r="",i,s;if(e.type===n.parser.STRING_LITERAL||e.type===n.parser.ID)r+=l(e);else{if(!(e.def&&e.def.length>0))throw k;if(e.def[0].type===n.parser.CONDITIONAL_EXPR)r+=f(e.def[0]);else for(t=0;t<e.def.length;t++)s=i,i=e.def[t],i.type===n.parser.TEXT?(i.val.match(/^\d+$/)||i.val.match(/^[_\$](?=(?:[^a-z0-9_$]|$))/i)||s&&s.type===n.parser.OPERATOR&&s.val==="."||(r+="$$."),r+=i.val):i.type===n.parser.OPERATOR?r+=i.val:i.type===n.parser.STRING_LITERAL&&(r+=l(i))}return r}function d(e){var t="",n,r;return n=e.def[0],r=p(n.def[0]),t+=r+" = new RLH();",t+=c(n.def[1]),n=e.def[1].def[0],t+=r+'["" + i] = ('+p(n.def[0])+" === i) ? ",t+=p(n.def[1])+" : "+p(n.def[2])+";",t+="}",L.RLH=!0,t}function v(e){var t="",n,r;return n=e.def[0],r=p(n.def[0]),t+=r+" = {};",t+=h(n.def[1]),n=e.def[1].def[0],t+=r+"[_set[i]] = ("+p(n.def[0])+" === _set[i]) ? ",t+=p(n.def[1])+" : "+p(n.def[2])+";",t+="}",t}function m(e){var t="",r;return r=e.def[0],r.def[r.def.length-1].type===n.parser.RANGE_LITERAL?t+=d(e):r.def[r.def.length-1].type===n.parser.SET_LITERAL?t+=v(e):(t+=p(r),t+=" =",t+=p(e.def[1]),t+=";"),t}function g(e){return L.extend=!0,L.cID=!0,'extend(cID,"'+e.id.val+'");'}function y(e){var t,n="",r;n+="partial(function($,$$){",n+="$$ = clone($$) || {};",n+='var i, ret = "", ret2, _;';for(t=1;t<e.def.length;t++)r=e.def[t],n+=m(r);return n+=T(e),n+="return ret;",n+='},"'+e.id.val+'"',n+=");",n}function b(e){var t="";return t+="ret2 = esc((function(){",t+='var ret = "", ret2;',t+=T(e),t+="return ret;",t+="})(),"+JSON.stringify(e.escapes)+");",t+=N("ret","ret2"),L.esc=!0,t}function w(e){var t,r="",i;r+="ret2 = (function(){",r+="function __iter__($,$$,value,key,index){",r+='var i, ret = "", ret2, _;',r+="if (value == null) return ret;",r+="$$ = clone($$);",r+="_ = {",r+="value: value,",r+="key: key,",r+="index: index,",r+="even: (index % 2) === 0,",r+="odd: (index % 2) === 1,",r+="first: (index === 0),",r+="last: (index === len - 1)",r+="};";for(t=1;t<e.def.length;t++)i=e.def[t],r+=m(i);return r+=T(e),r+="return ret;",r+="}",r+='var i, j = 0, len, ret = "", it, tmp;',e.main_expr.def[0].type===n.parser.SET_LITERAL?(r+=h(e.main_expr.def[0]),r+="len = _set.length;",r+='ret2 = __iter__($,$$,_set[i],""+i,i);',r+=N("ret","ret2"),r+="}"):e.main_expr.def[0].type===n.parser.RANGE_LITERAL?(r+="len = "+(Math.abs(e.main_expr.def[0].def[0].val-e.main_expr.def[0].def[1].val)+1)+";",r+=c(e.main_expr.def[0]),r+='ret2 = __iter__($,$$,i,""+i,j++);',r+=N("ret","ret2"),r+="}"):(r+="it = "+p(e.main_expr)+";",r+="if (it == null) {",r+='return "";',r+="}",r+="if (Array.isArray(it)) {",r+="len = it.length;",r+="for (i=0; i<len; i++) {",r+='ret2 = __iter__($,$$,it[i],""+i,i);',r+=N("ret","ret2"),r+="}",r+='} else if (typeof it === "object") {',r+="tmp = Object.keys(it);",r+="len = tmp.length;",r+="if (it instanceof RLH) {",r+="tmp.sort(__sort_fn__);",r+="}",r+="for (i=0; i<len; i++) {",r+="ret2 = __iter__($,$$,it[tmp[i]],tmp[i],i);",r+=N("ret","ret2"),r+="}",r+="} else {",r+="return ",r+="unerr;",r+="}",L.sort=!0,L.RLH=!0,L.unerr=!0),r+="return ret;",r+="})();",r+=N("ret","ret2"),r}function E(e){var t,n="",r;n+="ret2 = (function($,$$){",n+="$$ = clone($$) || {};",n+='var i, ret = "", ret2, _;';for(t=0;t<e.def.length;t++)r=e.def[t],n+=m(r);return n+=T(e),n+="return ret;",n+="})($,$$);",n+=N("ret","ret2"),n}function S(e){var t="",n;return n=p(e.context_expr),t+="ret2 = "+n+";",t+="ret2 = G.render("+p(e.main_expr)+",ret2,$$);",e.escapes&&(t+="ret2 = esc(ret2,"+JSON.stringify(e.escapes)+");",L.esc=!0),t+=N("ret","ret2"),t}function x(e){var t="",n=p(e.main_expr);return e.escapes?(t+="ret += esc("+n+","+JSON.stringify(e.escapes)+");",L.esc=!0):t+="ret += "+n+";",t}function T(e){var t,o="",u;for(t=0;t<e.children.length;t++)u=e.children[t],u.type===n.parser.TEXT?o+='ret += "'+i(s(r(u.val)))+'";':u.type===n.parser.TAG_LOOP?o+=w(u):u.type===n.parser.TAG_LET?o+=E(u):u.type===n.parser.TAG_INCL_TMPL?o+=S(u):u.type===n.parser.TAG_INSERT_VAR?o+=x(u):u.type===n.parser.TAG_ESCAPE&&(o+=b(u));return o}function N(e,t){var n="";return n+=e+" += "+t+";",n}function C(e){var t,r=[],i="",s="",f,l;while(t=n.parser.parseNextNode()){r.push(t);if(t.type===n.parser.COLLECTION_MARKER)t.start?(L={},f=u(t),L.cID_value=t.start,i+=f,s+=f):t.close&&(l=o(L),f=a(t),i+=f,i=i.replace(/\/\*startCollection\*\//,l),s+=f,s=s.replace(/\/\*startCollection\*\//,l),e&&n.initializeCollection(t.close,i),i="");else if(t.type===n.parser.TAG_EXTEND){if(!(r.length>1&&r[r.length-2].type===n.parser.COLLECTION_MARKER))throw k;f=g(t),i+=f,s+=f}else{if(t.type!==n.parser.TAG_DEFINE)throw k;f=y(t),i+=f,s+=f}}return s}var k=new Error("Unknown error"),L;n.generator={process:C}}(this,this.grips);var t=this.grips;typeof define=="function"&&define.amd&&define(t)}).call({});