liquidjs
Version:
A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
1 lines • 60.8 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).liquidjs={})}(this,function(p){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function t(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var m=function(){return(m=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function s(s,o,a,u){return new(a=a||Promise)(function(t,e){function r(t){try{i(u.next(t))}catch(t){e(t)}}function n(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(r,n)}i((u=u.apply(s,o||[])).next())})}function S(r,n){var i,s,o,t,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,s=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(o=0<(o=a.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){a.label=e[1];break}if(6===e[0]&&a.label<o[1]){a.label=o[1],o=e;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(e);break}o[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(r,a)}catch(t){e=[6,t],s=0}finally{i=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function q(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function w(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||0<e--)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function T(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(w(arguments[e]));return t}var i=(e.prototype.valueOf=function(){},e.prototype.liquidMethodMissing=function(t){},e);function e(){}var r=Object.prototype.toString,o=String.prototype.toLowerCase;function a(t){return"[object String]"===r.call(t)}function u(t){return"function"==typeof t}function c(t){return h(t=f(t))?"":String(t)}function f(t){return t instanceof i?t.valueOf():t}function l(t){return"number"==typeof t}function h(t){return null==t}function d(t){return"[object Array]"===r.call(t)}function v(t,e){for(var r in t=t||{})if(t.hasOwnProperty(r)&&!1===e(t[r],r,t))break;return t}function g(t){return t[t.length-1]}function y(t){var e=typeof t;return null!==t&&("object"==e||"function"==e)}function b(t,e,r){void 0===r&&(r=1);for(var n=[],i=t;i<e;i+=r)n.push(i);return n}function k(t,e,r){return void 0===r&&(r=" "),x(t,e,r,function(t,e){return e+t})}function x(t,e,r,n){for(var i=e-(t=String(t)).length;0<i--;)t=n(t,r);return t}function O(t){return t}function E(t){return t.replace(/(\w?)([A-Z])/g,function(t,e,r){return(e?e+"_":"")+r.toLowerCase()})}function R(t,e){return null==t&&null==e?0:null==t?1:null==e?-1:(t=o.call(t))<(e=o.call(e))?-1:e<t?1:0}var L=function(t,e,r,n){this.key=t,this.value=e,this.next=r,this.prev=n},F=(M.prototype.write=function(t,e){if(this.cache[t])this.cache[t].value=e;else{var r=new L(t,e,this.head.next,this.head);this.head.next.prev=r,this.head.next=r,this.cache[t]=r,this.size++,this.ensureLimit()}},M.prototype.read=function(t){if(this.cache[t]){var e=this.cache[t].value;return this.remove(t),this.write(t,e),e}},M.prototype.remove=function(t){var e=this.cache[t];e.prev.next=e.next,e.next.prev=e.prev,delete this.cache[t],this.size--},M.prototype.clear=function(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}},M.prototype.ensureLimit=function(){this.size>this.limit&&this.remove(this.tail.prev.key)},M);function M(t,e){void 0===e&&(e=0),this.limit=t,this.size=e,this.cache={},this.head=new L("HEAD",null,null,null),this.tail=new L("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}var D=Object.freeze({resolve:function(t,e,i){return t.length&&"/"!==g(t)&&(t+="/"),function(t,e){var r=document.createElement("base");r.href=t;var n=document.getElementsByTagName("head")[0];n.insertBefore(r,n.firstChild);var i=document.createElement("a");i.href=e;var s=i.href;return n.removeChild(r),s}(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,function(t,e,r){var n=r.split("/").pop();return/\.\w+$/.test(n)?t:e+r+i})},readFile:function(n){return s(this,void 0,void 0,function(){return S(this,function(t){return[2,new Promise(function(t,e){var r=new XMLHttpRequest;r.onload=function(){200<=r.status&&r.status<300?t(r.responseText):e(new Error(r.statusText))},r.onerror=function(){e(new Error("An error occurred whilst receiving the response."))},r.open("GET",n),r.send()})]})})},readFileSync:function(t){var e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),e.status<200||300<=e.status)throw new Error(e.statusText);return e.responseText},exists:function(t){return s(this,void 0,void 0,function(){return S(this,function(t){return[2,!0]})})},existsSync:function(t){return!0}});function N(t){return t&&u(t.equals)}function P(t,e){return!A(t,e)}function A(t,e){return e.opts.jsTruthy?!t:!1===t||null==t}var I={"==":function(t,e){return N(t)?t.equals(e):N(e)?e.equals(t):t===e},"!=":function(t,e){return N(t)?!t.equals(e):N(e)?!e.equals(t):t!==e},">":function(t,e){return N(t)?t.gt(e):N(e)?e.lt(t):e<t},"<":function(t,e){return N(t)?t.lt(e):N(e)?e.gt(t):t<e},">=":function(t,e){return N(t)?t.geq(e):N(e)?e.leq(t):e<=t},"<=":function(t,e){return N(t)?t.leq(e):N(e)?e.geq(t):t<=e},contains:function(t,e){return!(!t||!u(t.indexOf))&&-1<t.indexOf(e)},and:function(t,e,r){return P(t,r)&&P(e,r)},or:function(t,e,r){return P(t,r)||P(e,r)}},V=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],_=1,j=4,B=16;function z(t){var e,r,n={};try{for(var i=q(Object.entries(t)),s=i.next();!s.done;s=i.next()){for(var o=w(s.value,2),a=o[0],u=o[1],c=n,l=0;l<a.length;l++){var h=a[l];c[h]=c[h]||{},l===a.length-1&&V[a.charCodeAt(l)]&_&&(c[h].needBoundary=!0),c=c[h]}c.handler=u,c.end=!0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}V[160]=V[5760]=V[6158]=V[8192]=V[8193]=V[8194]=V[8195]=V[8196]=V[8197]=V[8198]=V[8199]=V[8200]=V[8201]=V[8202]=V[8232]=V[8233]=V[8239]=V[8287]=V[12288]=j;var C={root:["."],cache:void 0,extname:"",fs:D,dynamicPartials:!0,jsTruthy:!1,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,lenientIf:!1,globals:{},keepOutputType:!1,operators:I,operatorsTrie:z(I)};function H(t){if((t=t||{}).hasOwnProperty("root")&&(t.root=K(t.root)),t.hasOwnProperty("cache")){var e=void 0;e="number"==typeof t.cache?0<t.cache?new F(t.cache):void 0:"object"==typeof t.cache?t.cache:t.cache?new F(1024):void 0,t.cache=e}return t.hasOwnProperty("operators")&&(t.operatorsTrie=z(t.operators)),t}function K(t){return d(t)?t:a(t)?[t]:[]}var U,Q=(t(W,U=Error),W.prototype.update=function(){var t=this.originalError;this.context=function(t){var e=w(t.getPosition(),1)[0],r=t.input.split("\n"),n=Math.max(e-2,1),i=Math.min(e+3,r.length);return b(n,i+1).map(function(t){return(t===e?">> ":" ")+k(String(t),String(i).length)+"| "+r[t-1]}).join("\n")}(this.token),this.message=function(t,e){e.file&&(t+=", file:"+e.file);var r=w(e.getPosition(),2),n=r[0],i=r[1];return t+=", line:"+n+", col:"+i}(t.message,this.token),this.stack=this.message+"\n"+this.context+"\n"+this.stack+"\nFrom "+t.stack},W);function W(t,e){var r=U.call(this,t.message)||this;return r.originalError=t,r.token=e,r.context="",r}var J,Y=(t(Z,J=Q),Z);function Z(t,e){var r=J.call(this,new Error(t),e)||this;return r.name="TokenizationError",J.prototype.update.call(r),r}var $,G=(t(X,$=Q),X);function X(t,e){var r=$.call(this,t,e)||this;return r.name="ParseError",r.message=t.message,$.prototype.update.call(r),r}var tt,et=(t(rt,tt=Q),rt.is=function(t){return"RenderError"===t.name},rt);function rt(t,e){var r=tt.call(this,t,e.token)||this;return r.name="RenderError",r.message=t.message,tt.prototype.update.call(r),r}var nt,it=(t(st,nt=Q),st);function st(t,e){var r=nt.call(this,t,e)||this;return r.name="UndefinedVariableError",r.message=t.message,nt.prototype.update.call(r),r}var ot,at=(t(ut,ot=Error),ut);function ut(t){var e=ot.call(this,"undefined variable: "+t)||this;return e.name="InternalUndefinedVariableError",e.variableName=t,e}var ct,lt=(t(ht,ct=Error),ht);function ht(t){var e=ct.call(this,t)||this;return e.name="AssertionError",e.message=t+"",e}var pt,ft=(dt.prototype.getRegister=function(t,e){return void 0===e&&(e={}),this.registers[t]=this.registers[t]||e},dt.prototype.setRegister=function(t,e){return this.registers[t]=e},dt.prototype.saveRegister=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.map(function(t){return[t,e.getRegister(t)]})},dt.prototype.restoreRegister=function(t){var i=this;return t.forEach(function(t){var e=w(t,2),r=e[0],n=e[1];return i.setRegister(r,n)})},dt.prototype.getAll=function(){return T([this.globals,this.environments],this.scopes).reduce(function(t,e){return m(t,e)},{})},dt.prototype.get=function(t){var e=this.findScope(t[0]);return this.getFromScope(e,t)},dt.prototype.getFromScope=function(t,e){var r=this;return"string"==typeof e&&(e=e.split(".")),e.reduce(function(t,e){if(h(t=function(t,e){return h(t)?t:u((t=function t(e){return e&&u(e.toLiquid)?t(e.toLiquid()):e}(t))[e])?t[e]():t instanceof i?t.hasOwnProperty(e)?t[e]:t.liquidMethodMissing(e):"size"===e?function(t){return d(t)||a(t)?t.length:t.size}(t):"first"===e?function(t){return d(t)?t[0]:t.first}(t):"last"===e?function(t){return d(t)?t[t.length-1]:t.last}(t):t[e]}(t,e))&&r.opts.strictVariables)throw new at(e);return t},t)},dt.prototype.push=function(t){return this.scopes.push(t)},dt.prototype.pop=function(){return this.scopes.pop()},dt.prototype.bottom=function(){return this.scopes[0]},dt.prototype.findScope=function(t){for(var e=this.scopes.length-1;0<=e;e--){var r=this.scopes[e];if(t in r)return r}return t in this.environments?this.environments:this.globals},dt);function dt(t,e,r){void 0===t&&(t={}),void 0===e&&(e=C),void 0===r&&(r=!1),this.scopes=[{}],this.registers={},this.sync=r,this.opts=e,this.globals=e.globals,this.environments=t}function vt(t){return!!(qt(t)&p.TokenKind.Delimited)}function gt(t){return qt(t)===p.TokenKind.Operator}function yt(t){return qt(t)===p.TokenKind.HTML}function mt(t){return qt(t)===p.TokenKind.Output}function wt(t){return qt(t)===p.TokenKind.Tag}function Tt(t){return qt(t)===p.TokenKind.Quoted}function bt(t){return qt(t)===p.TokenKind.Literal}function kt(t){return qt(t)===p.TokenKind.Number}function xt(t){return qt(t)===p.TokenKind.PropertyAccess}function Ot(t){return qt(t)===p.TokenKind.Word}function St(t){return qt(t)===p.TokenKind.Range}function qt(t){return t?t.kind:-1}(pt=p.TokenKind||(p.TokenKind={}))[pt.Number=1]="Number",pt[pt.Literal=2]="Literal",pt[pt.Tag=4]="Tag",pt[pt.Output=8]="Output",pt[pt.HTML=16]="HTML",pt[pt.Filter=32]="Filter",pt[pt.Hash=64]="Hash",pt[pt.PropertyAccess=128]="PropertyAccess",pt[pt.Word=256]="Word",pt[pt.Range=512]="Range",pt[pt.Quoted=1024]="Quoted",pt[pt.Operator=2048]="Operator",pt[pt.Delimited=12]="Delimited";var Et=Object.freeze({isDelimitedToken:vt,isOperatorToken:gt,isHTMLToken:yt,isOutputToken:mt,isTagToken:wt,isQuotedToken:Tt,isLiteralToken:bt,isNumberToken:kt,isPropertyAccessToken:xt,isWordToken:Ot,isRangeToken:St});function Rt(t,e){if(t&&yt(t))for(var r=e?j:B;V[t.input.charCodeAt(t.end-1-t.trimRight)]&r;)t.trimRight++}function Lt(t,e){if(t&&yt(t)){for(var r=e?j:B;V[t.input.charCodeAt(t.begin+t.trimLeft)]&r;)t.trimLeft++;"\n"===t.input.charAt(t.begin+t.trimLeft)&&t.trimLeft++}}var Ft=(Mt.prototype.getText=function(){return this.input.slice(this.begin,this.end)},Mt.prototype.getPosition=function(){for(var t=w([1,1],2),e=t[0],r=t[1],n=0;n<this.begin;n++)"\n"===this.input[n]?(e++,r=1):r++;return[e,r]},Mt.prototype.size=function(){return this.end-this.begin},Mt);function Mt(t,e,r,n,i){this.kind=t,this.input=e,this.begin=r,this.end=n,this.file=i}var Dt,Nt=(t(Pt,Dt=Ft),Pt);function Pt(t,e){var r=Dt.call(this,p.TokenKind.Number,t.input,t.begin,e?e.end:t.end,t.file)||this;return r.whole=t,r.decimal=e,r}var At,It=(t(Vt,At=Ft),Vt.prototype.isNumber=function(t){void 0===t&&(t=!1);for(var e=t&&64&V[this.input.charCodeAt(this.begin)]?this.begin+1:this.begin;e<this.end;e++)if(!(32&V[this.input.charCodeAt(e)]))return!1;return!0},Vt);function Vt(t,e,r,n){var i=At.call(this,p.TokenKind.Word,t,e,r,n)||this;return i.input=t,i.begin=e,i.end=r,i.file=n,i.content=i.getText(),i}var _t,jt=(t(Bt,_t=i),Bt.prototype.equals=function(t){return h(f(t))},Bt.prototype.gt=function(){return!1},Bt.prototype.geq=function(){return!1},Bt.prototype.lt=function(){return!1},Bt.prototype.leq=function(){return!1},Bt.prototype.valueOf=function(){return null},Bt);function Bt(){return null!==_t&&_t.apply(this,arguments)||this}var zt,Ct=(t(Ht,zt=i),Ht.prototype.equals=function(t){return!(t instanceof Ht||(a(t=f(t))||d(t)?0!==t.length:!y(t)||0!==Object.keys(t).length))},Ht.prototype.gt=function(){return!1},Ht.prototype.geq=function(){return!1},Ht.prototype.lt=function(){return!1},Ht.prototype.leq=function(){return!1},Ht.prototype.valueOf=function(){return""},Ht);function Ht(){return null!==zt&&zt.apply(this,arguments)||this}var Kt,Ut=(t(Qt,Kt=Ct),Qt.prototype.equals=function(t){return!1===t||!!h(f(t))||(a(t)?/^\s*$/.test(t):Kt.prototype.equals.call(this,t))},Qt);function Qt(){return null!==Kt&&Kt.apply(this,arguments)||this}var Wt,Jt=new jt,Yt={true:!0,false:!1,nil:Jt,null:Jt,empty:new Ct,blank:new Ut},Zt=(t($t,Wt=Ft),$t);function $t(t,e,r,n){var i=Wt.call(this,p.TokenKind.Literal,t,e,r,n)||this;return i.input=t,i.begin=e,i.end=r,i.file=n,i.literal=i.getText(),i}var Gt,Xt={"==":1,"!=":1,">":1,"<":1,">=":1,"<=":1,contains:1,and:0,or:0},te=(t(ee,Gt=Ft),ee.prototype.getPrecedence=function(){var t=this.getText();return t in Xt?Xt[t]:1},ee);function ee(t,e,r,n){var i=Gt.call(this,p.TokenKind.Operator,t,e,r,n)||this;return i.input=t,i.begin=e,i.end=r,i.file=n,i.operator=i.getText(),i}var re=/[\da-fA-F]/,ne=/[0-7]/,ie={b:"\b",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v"};function se(t){var e=t.charCodeAt(0);return 97<=e?e-87:65<=e?e-55:e-48}function oe(t){for(var e="",r=1;r<t.length-1;r++)if("\\"===t[r])if(void 0!==ie[t[r+1]])e+=ie[t[++r]];else if("u"===t[r+1]){for(var n=0,i=r+2;i<=r+5&&re.test(t[i]);)n=16*n+se(t[i++]);r=i-1,e+=String.fromCharCode(n)}else if(ne.test(t[r+1])){for(i=r+1,n=0;i<=r+3&&ne.test(t[i]);)n=8*n+se(t[i++]);r=i-1,e+=String.fromCharCode(n)}else e+=t[++r];else e+=t[r];return e}var ae,ue=(t(ce,ae=Ft),ce.prototype.getVariableAsText=function(){return this.variable instanceof It?this.variable.getText():oe(this.variable.getText())},ce);function ce(t,e,r){var n=ae.call(this,p.TokenKind.PropertyAccess,t.input,t.begin,r,t.file)||this;return n.variable=t,n.props=e,n}function le(t,e){if(!t){var r=e?e():"expect "+t+" to be true";throw new lt(r)}}var he,pe=(t(fe,he=Ft),fe);function fe(t,e,r,n,i,s){var o=he.call(this,p.TokenKind.Filter,r,n,i,s)||this;return o.name=t,o.args=e,o}var de,ve=(t(ge,de=Ft),ge);function ge(t,e,r,n,i,s){var o=de.call(this,p.TokenKind.Hash,t,e,r,s)||this;return o.input=t,o.begin=e,o.end=r,o.name=n,o.value=i,o.file=s,o}var ye,me=(t(we,ye=Ft),we);function we(t,e,r,n){var i=ye.call(this,p.TokenKind.Quoted,t,e,r,n)||this;return i.input=t,i.begin=e,i.end=r,i.file=n,i}var Te,be=(t(ke,Te=Ft),ke.prototype.getContent=function(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)},ke);function ke(t,e,r,n){var i=Te.call(this,p.TokenKind.HTML,t,e,r,n)||this;return i.input=t,i.begin=e,i.end=r,i.file=n,i.trimLeft=0,i.trimRight=0,i}var xe,Oe=(t(Se,xe=Ft),Se);function Se(t,e,r,n,i,s,o,a){var u=xe.call(this,t,r,n,i,a)||this;u.trimLeft=!1,u.trimRight=!1,u.content=u.getText();var c="-"===e[0],l="-"===g(e);return u.content=e.slice(c?1:0,l?-1:e.length).trim(),u.trimLeft=c||s,u.trimRight=l||o,u}var qe,Ee=(t(Re,qe=Oe),Re);function Re(t,e,r,n,i){var s=this,o=n.trimTagLeft,a=n.trimTagRight,u=n.tagDelimiterLeft,c=n.tagDelimiterRight,l=t.slice(e+u.length,r-c.length);s=qe.call(this,p.TokenKind.Tag,l,t,e,r,o,a,i)||this;var h=new je(s.content,n.operatorsTrie);if(s.name=h.readIdentifier().getText(),!s.name)throw new Y("illegal tag syntax",s);return h.skipBlank(),s.args=h.remaining(),s}var Le,Fe=(t(Me,Le=Ft),Me);function Me(t,e,r,n,i,s){var o=Le.call(this,p.TokenKind.Range,t,e,r,s)||this;return o.input=t,o.begin=e,o.end=r,o.lhs=n,o.rhs=i,o.file=s,o}var De,Ne=(t(Pe,De=Oe),Pe);function Pe(t,e,r,n,i){var s=n.trimOutputLeft,o=n.trimOutputRight,a=n.outputDelimiterLeft,u=n.outputDelimiterRight,c=t.slice(e+a.length,r-u.length);return De.call(this,p.TokenKind.Output,c,t,e,r,s,o,i)||this}var Ae=(Ie.prototype.evaluate=function(e,r){var n,i,s,o,a,u,c,l,h,p,f,d;return S(this,function(t){switch(t.label){case 0:le(e,function(){return"unable to evaluate: context not defined"}),n=[],t.label=1;case 1:t.trys.push([1,9,10,11]),i=q(this.postfix),s=i.next(),t.label=2;case 2:return s.done?[3,8]:gt(o=s.value)?[4,n.pop()]:[3,5];case 3:return a=t.sent(),[4,n.pop()];case 4:return u=t.sent(),c=function(t,e,r,n,i){return(0,t[e.operator])(r,n,i)}(e.opts.operators,o,u,a,e),n.push(c),[3,7];case 5:return h=(l=n).push,[4,Ve(o,e,r&&1===this.postfix.length)];case 6:h.apply(l,[t.sent()]),t.label=7;case 7:return s=i.next(),[3,2];case 8:return[3,11];case 9:return p=t.sent(),f={error:p},[3,11];case 10:try{s&&!s.done&&(d=i.return)&&d.call(i)}finally{if(f)throw f.error}return[7];case 11:return[2,n[0]]}})},Ie);function Ie(t){this.postfix=T(function(e){var r,n,i,s,o,a,u;return S(this,function(t){switch(t.label){case 0:r=[],t.label=1;case 1:t.trys.push([1,10,11,12]),n=q(e),i=n.next(),t.label=2;case 2:if(i.done)return[3,9];if(!gt(s=i.value))return[3,6];t.label=3;case 3:return r.length&&r[r.length-1].getPrecedence()>s.getPrecedence()?[4,r.pop()]:[3,5];case 4:return t.sent(),[3,3];case 5:return r.push(s),[3,8];case 6:return[4,s];case 7:t.sent(),t.label=8;case 8:return i=n.next(),[3,2];case 9:return[3,12];case 10:return o=t.sent(),a={error:o},[3,12];case 11:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(a)throw a.error}return[7];case 12:return r.length?[4,r.pop()]:[3,14];case 13:return t.sent(),[3,12];case 14:return[2]}})}(t))}function Ve(t,e,r){return void 0===r&&(r=!1),xt(t)?function(e,r,n){var t=e.getVariableAsText(),i=e.props.map(function(t){return Ve(t,r,!1)});try{return r.get(T([t],i))}catch(t){if(n&&"InternalUndefinedVariableError"===t.name)return null;throw new it(t,e)}}(t,e,r):St(t)?function(t,e){var r=Ve(t.lhs,e),n=Ve(t.rhs,e);return b(+r,+n+1)}(t,e):bt(t)?function(t){return Yt[t.literal]}(t):kt(t)?function(t){var e=t.whole.content+"."+(t.decimal?t.decimal.content:"");return Number(e)}(t):Ot(t)?t.getText():Tt(t)?_e(t):void 0}function _e(t){return oe(t.getText())}var je=(Be.prototype.readExpression=function(){return new Ae(this.readExpressionTokens())},Be.prototype.readExpressionTokens=function(){var e,r,n;return S(this,function(t){switch(t.label){case 0:return(e=this.readValue())?[4,e]:[2];case 1:t.sent(),t.label=2;case 2:return this.p<this.N?(r=this.readOperator())&&(n=this.readValue())?[4,r]:[2]:[3,5];case 3:return t.sent(),[4,n];case 4:return t.sent(),[3,2];case 5:return[2]}})},Be.prototype.readOperator=function(){this.skipBlank();var t=function(t,e,r,n){void 0===n&&(n=t.length);for(var i,s=r,o=e;s[t[o]]&&o<n;)(s=s[t[o++]]).end&&(i=s);return i?i.needBoundary&&V[t.charCodeAt(o)]&_?-1:o:-1}(this.input,this.p,this.trie,this.p+8);if(-1!==t)return new te(this.input,this.p,this.p=t,this.file)},Be.prototype.readFilters=function(){for(var t=[];;){var e=this.readFilter();if(!e)return t;t.push(e)}},Be.prototype.readFilter=function(){var t=this;if(this.skipBlank(),this.end())return null;le("|"===this.peek(),function(){return"unexpected token at "+t.snapshot()}),this.p++;var e=this.p,r=this.readIdentifier();if(!r.size())return null;var n=[];if(this.skipBlank(),":"===this.peek())do{++this.p;var i=this.readFilterArg();for(i&&n.push(i);this.p<this.N&&","!==this.peek()&&"|"!==this.peek();)++this.p}while(","===this.peek());return new pe(r.getText(),n,this.input,e,this.p,this.file)},Be.prototype.readFilterArg=function(){var t=this.readValue();if(t){if(this.skipBlank(),":"!==this.peek())return t;++this.p;var e=this.readValue();return[t.getText(),e]}},Be.prototype.readTopLevelTokens=function(t){void 0===t&&(t=C);for(var e=[];this.p<this.N;){var r=this.readTopLevelToken(t);e.push(r)}return function(t,e){for(var r=!1,n=0;n<t.length;n++){var i=t[n];vt(i)&&(!r&&i.trimLeft&&Rt(t[n-1],e.greedy),wt(i)&&("raw"===i.name?r=!0:"endraw"===i.name&&(r=!1)),!r&&i.trimRight&&Lt(t[n+1],e.greedy))}}(e,t),e},Be.prototype.readTopLevelToken=function(t){var e=t.tagDelimiterLeft,r=t.outputDelimiterLeft;return-1<this.rawBeginAt?this.readEndrawOrRawContent(t):this.match(e)?this.readTagToken(t):this.match(r)?this.readOutputToken(t):this.readHTMLToken(t)},Be.prototype.readHTMLToken=function(t){for(var e=this.p;this.p<this.N;){var r=t.tagDelimiterLeft,n=t.outputDelimiterLeft;if(this.match(r))break;if(this.match(n))break;++this.p}return new be(this.input,e,this.p,this.file)},Be.prototype.readTagToken=function(t){void 0===t&&(t=C);var e=this.file,r=this.input,n=this.p;if(-1===this.readToDelimiter(t.tagDelimiterRight))throw this.mkError("tag "+this.snapshot(n)+" not closed",n);var i=new Ee(r,n,this.p,t,e);return"raw"===i.name&&(this.rawBeginAt=n),i},Be.prototype.readToDelimiter=function(t){for(;this.p<this.N;)if(8&this.peekType())this.readQuoted();else if(++this.p,this.rmatch(t))return this.p;return-1},Be.prototype.readOutputToken=function(t){void 0===t&&(t=C);var e=this.file,r=this.input,n=t.outputDelimiterRight,i=this.p;if(-1===this.readToDelimiter(n))throw this.mkError("output "+this.snapshot(i)+" not closed",i);return new Ne(r,i,this.p,t,e)},Be.prototype.readEndrawOrRawContent=function(t){for(var e=t.tagDelimiterLeft,r=t.tagDelimiterRight,n=this.p,i=this.readTo(e)-e.length;this.p<this.N;)if("endraw"===this.readIdentifier().getText())for(;this.p<=this.N;){if(this.rmatch(r)){var s=this.p;return n===i?(this.rawBeginAt=-1,new Ee(this.input,n,s,t,this.file)):(this.p=i,new be(this.input,n,i,this.file))}if(this.rmatch(e))break;this.p++}else i=this.readTo(e)-e.length;throw this.mkError("raw "+this.snapshot(this.rawBeginAt)+" not closed",n)},Be.prototype.mkError=function(t,e){return new Y(t,new It(this.input,e,this.N,this.file))},Be.prototype.snapshot=function(t){return void 0===t&&(t=this.p),JSON.stringify(function(t,e){return t.length>e?t.substr(0,e-3)+"...":t}(this.input.slice(t),16))},Be.prototype.readWord=function(){return console.warn("Tokenizer#readWord() will be removed, use #readIdentifier instead"),this.readIdentifier()},Be.prototype.readIdentifier=function(){this.skipBlank();for(var t=this.p;this.peekType()&_;)++this.p;return new It(this.input,t,this.p,this.file)},Be.prototype.readHashes=function(){for(var t=[];;){var e=this.readHash();if(!e)return t;t.push(e)}},Be.prototype.readHash=function(){this.skipBlank(),","===this.peek()&&++this.p;var t,e=this.p,r=this.readIdentifier();if(r.size())return this.skipBlank(),":"===this.peek()&&(++this.p,t=this.readValue()),new ve(this.input,e,this.p,r,t,this.file)},Be.prototype.remaining=function(){return this.input.slice(this.p)},Be.prototype.advance=function(t){void 0===t&&(t=1),this.p+=t},Be.prototype.end=function(){return this.p>=this.N},Be.prototype.readTo=function(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1},Be.prototype.readValue=function(){var t=this.readQuoted()||this.readRange();if(t)return t;if("["===this.peek()){if(this.p++,!(i=this.readQuoted()))return;if("]"!==this.peek())return;return this.p++,new ue(i,[],this.p)}var e=this.readIdentifier();if(e.size()){for(var r=e.isNumber(!0),n=[];;)if("["===this.peek()){r=!1,this.p++;var i=this.readValue()||new It(this.input,this.p,this.p,this.file);this.readTo("]"),n.push(i)}else{if("."!==this.peek()||"."===this.peek(1))break;if(this.p++,!(i=this.readIdentifier()).size())break;i.isNumber()||(r=!1),n.push(i)}return!n.length&&Yt.hasOwnProperty(e.content)?new Zt(this.input,e.begin,e.end,this.file):r?new Nt(e,n[0]):new ue(e,n,this.p)}},Be.prototype.readRange=function(){this.skipBlank();var t=this.p;if("("===this.peek()){++this.p;var e=this.readValueOrThrow();this.p+=2;var r=this.readValueOrThrow();return++this.p,new Fe(this.input,t,this.p,e,r,this.file)}},Be.prototype.readValueOrThrow=function(){var t=this,e=this.readValue();return le(e,function(){return"unexpected token "+t.snapshot()+", value expected"}),e},Be.prototype.readQuoted=function(){this.skipBlank();var t=this.p;if(8&this.peekType()){++this.p;for(var e=!1;this.p<this.N&&(++this.p,this.input[this.p-1]!==this.input[t]||e);)e?e=!1:"\\"===this.input[this.p-1]&&(e=!0);return new me(this.input,t,this.p,this.file)}},Be.prototype.readFileName=function(){for(var t=this.p;!(this.peekType()&j)&&","!==this.peek()&&this.p<this.N;)this.p++;return new It(this.input,t,this.p,this.file)},Be.prototype.match=function(t){for(var e=0;e<t.length;e++)if(t[e]!==this.input[this.p+e])return!1;return!0},Be.prototype.rmatch=function(t){for(var e=0;e<t.length;e++)if(t[t.length-1-e]!==this.input[this.p-1-e])return!1;return!0},Be.prototype.peekType=function(t){return void 0===t&&(t=0),V[this.input.charCodeAt(this.p+t)]},Be.prototype.peek=function(t){return void 0===t&&(t=0),this.input[this.p+t]},Be.prototype.skipBlank=function(){for(;this.peekType()&j;)++this.p},Be);function Be(t,e,r){void 0===r&&(r=""),this.input=t,this.trie=e,this.file=r,this.p=0,this.rawBeginAt=-1,this.N=t.length}var ze=(Ce.prototype.write=function(t){t=!0===this.keepOutputType?f(t):c(f(t)),!0===this.keepOutputType&&"string"!=typeof t&&""===this.html?this.html=t:this.html=c(this.html)+c(t)},Ce);function Ce(t){this.html="",this.break=!1,this.continue=!1,this.keepOutputType=!1,this.keepOutputType=t}var He=(Ke.prototype.renderTemplates=function(e,r,n){var i,s,o,a,u,c,l,h;return S(this,function(t){switch(t.label){case 0:n=n||new ze(r.opts.keepOutputType),t.label=1;case 1:t.trys.push([1,8,9,10]),i=q(e),s=i.next(),t.label=2;case 2:if(s.done)return[3,7];o=s.value,t.label=3;case 3:return t.trys.push([3,5,,6]),[4,o.render(r,n)];case 4:return(a=t.sent())&&n.write(a),n.break||n.continue?[3,7]:[3,6];case 5:throw u=t.sent(),et.is(u)?u:new et(u,o);case 6:return s=i.next(),[3,2];case 7:return[3,10];case 8:return c=t.sent(),l={error:c},[3,10];case 9:try{s&&!s.done&&(h=i.return)&&h.call(i)}finally{if(l)throw l.error}return[7];case 10:return[2,n.html]}})},Ke);function Ke(){}var Ue=(Qe.prototype.on=function(t,e){return this.handlers[t]=e,this},Qe.prototype.trigger=function(t,e){var r=this.handlers[t];return!!r&&(r(e),!0)},Qe.prototype.start=function(){var t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());)if(!(this.trigger("token",t)||wt(t)&&this.trigger("tag:"+t.name,t))){var e=this.parseToken(t,this.tokens);this.trigger("template",e)}return this.stopRequested||this.trigger("end"),this},Qe.prototype.stop=function(){return this.stopRequested=!0,this},Qe);function Qe(t,e){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=e}function We(t){this.token=t}var Je=(Ye.prototype.render=function(e){var r,n,i,s,o,a,u,c,l;return S(this,function(t){switch(t.label){case 0:r={},t.label=1;case 1:t.trys.push([1,6,7,8]),n=q(Object.keys(this.hash)),i=n.next(),t.label=2;case 2:return i.done?[3,5]:(s=i.value,o=r,a=s,[4,Ve(this.hash[s],e)]);case 3:o[a]=t.sent(),t.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return u=t.sent(),c={error:u},[3,8];case 7:try{i&&!i.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 8:return[2,r]}})},Ye);function Ye(t){var e,r;this.hash={};var n=new je(t,{});try{for(var i=q(n.readHashes()),s=i.next();!s.done;s=i.next()){var o=s.value;this.hash[o.name.content]=o.value}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}var Ze=($e.prototype.render=function(t,e){var r,n,i=[];try{for(var s=q(this.args),o=s.next();!o.done;o=s.next()){var a=o.value;d(a)?i.push([a[0],Ve(a[1],e)]):i.push(Ve(a,e))}}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return this.impl.apply({context:e,liquid:this.liquid},T([t],i))},$e);function $e(t,e,r,n){this.name=t,this.impl=e||O,this.args=r,this.liquid=n}var Ge=(Xe.prototype.value=function(e,r){var n,i,s,o,a,u;return S(this,function(t){switch(t.label){case 0:return r=r||e.opts.lenientIf&&0<this.filters.length&&"default"===this.filters[0].name,[4,this.initial.evaluate(e,r)];case 1:n=t.sent(),t.label=2;case 2:t.trys.push([2,7,8,9]),i=q(this.filters),s=i.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value.render(n,e)];case 4:n=t.sent(),t.label=5;case 5:return s=i.next(),[3,3];case 6:return[3,9];case 7:return o=t.sent(),a={error:o},[3,9];case 8:try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}return[7];case 9:return[2,n]}})},Xe);function Xe(t,n){this.filters=[];var e=new je(t,n.options.operatorsTrie);this.initial=e.readExpression(),this.filters=e.readFilters().map(function(t){var e=t.name,r=t.args;return new Ze(e,n.filters.get(e),r,n)})}function tr(e){var t={then:function(t){return t(e)},catch:function(){return t}};return t}function er(r){var n={then:function(t,e){return e?e(r):n},catch:function(t){return t(r)}};return n}function rr(n){return function(t){return t&&u(t.then)}(n)?n:function(t){return t&&u(t.next)&&u(t.throw)&&u(t.return)}(n)?function r(t){var e;try{e=n.next(t)}catch(t){return er(t)}if(e.done)return tr(e.value);return rr(e.value).then(r,function(t){var e;try{e=n.throw(t)}catch(t){return er(t)}return e.done?tr(e.value):r(e.value)})}():tr(n)}function nr(t){return Promise.resolve(rr(t))}function ir(t){var e;return rr(t).then(function(t){return tr(e=t)}).catch(function(t){throw t}),e}var sr,or=(t(ar,sr=We),ar.prototype.render=function(e,r){var n,i;return S(this,function(t){switch(t.label){case 0:return[4,new Je(this.token.args).render(e)];case 1:return n=t.sent(),u((i=this.impl).render)?[4,i.render(e,r,n)]:[3,3];case 2:return[2,t.sent()];case 3:return[2]}})},ar);function ar(t,e,r){var n=sr.call(this,t)||this;n.name=t.name;var i=r.tags.get(t.name);return n.impl=Object.create(i),n.impl.liquid=r,n.impl.parse&&n.impl.parse(t,e),n}var ur,cr=(t(lr,ur=We),lr.prototype.render=function(e,r){var n;return S(this,function(t){switch(t.label){case 0:return[4,this.value.value(e,!1)];case 1:return n=t.sent(),r.write(n),[2]}})},lr);function lr(t,e){var r=ur.call(this,t)||this;return r.value=new Ge(t.content,e),r}var hr,pr=(t(fr,hr=We),fr.prototype.render=function(t,e){return S(this,function(t){return e.write(this.str),[2]})},fr);function fr(t){var e=hr.call(this,t)||this;return e.str=t.getContent(),e}var dr=(vr.prototype.parse=function(t){for(var e,r=[];e=t.shift();)r.push(this.parseToken(e,t));return r},vr.prototype.parseToken=function(e,t){try{return wt(e)?new or(e,t,this.liquid):mt(e)?new cr(e,this.liquid):new pr(e)}catch(t){throw new G(t,e)}},vr.prototype.parseStream=function(t){var r=this;return new Ue(t,function(t,e){return r.parseToken(t,e)})},vr);function vr(t){this.liquid=t}var gr={parse:function(t){var e=new je(t.args,this.liquid.options.operatorsTrie);this.key=e.readIdentifier().content,e.skipBlank(),le("="===e.peek(),function(){return"illegal token "+t.getText()}),e.advance(),this.value=e.remaining()},render:function(e){var r,n;return S(this,function(t){switch(t.label){case 0:return r=e.bottom(),n=this.key,[4,this.liquid._evalValue(this.value,e)];case 1:return r[n]=t.sent(),[2]}})}};function yr(e){return d(e)?e:a(e)&&0<e.length?[e]:y(e)?Object.keys(e).map(function(t){return[t,e[t]]}):[]}function mr(t){return d(t)?t:[t]}var wr,Tr=(t(br,wr=i),br.prototype.next=function(){this.i++},br.prototype.index0=function(){return this.i},br.prototype.index=function(){return this.i+1},br.prototype.first=function(){return 0===this.i},br.prototype.last=function(){return this.i===this.length-1},br.prototype.rindex=function(){return this.length-this.i},br.prototype.rindex0=function(){return this.length-this.i-1},br.prototype.valueOf=function(){return JSON.stringify(this)},br);function br(t){var e=wr.call(this)||this;return e.i=0,e.length=t,e}var kr={type:"block",parse:function(t,e){var r,n=this,i=new je(t.args,this.liquid.options.operatorsTrie),s=i.readIdentifier(),o=i.readIdentifier(),a=i.readValue();le(s.size()&&"in"===o.content&&a,function(){return"illegal tag: "+t.getText()}),this.variable=s.content,this.collection=a,this.hash=new Je(i.remaining()),this.templates=[],this.elseTemplates=[];var u=this.liquid.parser.parseStream(e).on("start",function(){return r=n.templates}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endfor",function(){return u.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});u.start()},render:function(e,r){var n,i,s,o,a,u,c,l,h,p,f,d,v;return S(this,function(t){switch(t.label){case 0:return n=this.liquid.renderer,s=yr,[4,Ve(this.collection,e)];case 1:return(i=s.apply(void 0,[t.sent()])).length?[3,3]:[4,n.renderTemplates(this.elseTemplates,e,r)];case 2:return t.sent(),[2];case 3:return[4,this.hash.render(e)];case 4:o=t.sent(),a=o.offset||0,u=void 0===o.limit?i.length:o.limit,i=i.slice(a,a+u),"reversed"in o&&i.reverse(),c={forloop:new Tr(i.length)},e.push(c),t.label=5;case 5:t.trys.push([5,10,11,12]),l=q(i),h=l.next(),t.label=6;case 6:return h.done?[3,9]:(p=h.value,c[this.variable]=p,[4,n.renderTemplates(this.templates,e,r)]);case 7:if(t.sent(),r.break)return r.break=!1,[3,9];r.continue=!1,c.forloop.next(),t.label=8;case 8:return h=l.next(),[3,6];case 9:return[3,12];case 10:return f=t.sent(),d={error:f},[3,12];case 11:try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(d)throw d.error}return[7];case 12:return e.pop(),[2]}})}},xr={parse:function(t,e){var r=this,n=new je(t.args,this.liquid.options.operatorsTrie);this.variable=function(t){var e=t.readIdentifier().content;if(e)return e;var r=t.readQuoted();if(r)return _e(r)}(n),le(this.variable,function(){return t.args+" not valid identifier"}),this.templates=[];var i=this.liquid.parser.parseStream(e);i.on("tag:endcapture",function(){return i.stop()}).on("template",function(t){return r.templates.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")}),i.start()},render:function(e){var r;return S(this,function(t){switch(t.label){case 0:return[4,this.liquid.renderer.renderTemplates(this.templates,e)];case 1:return r=t.sent(),e.bottom()[this.variable]=r,[2]}})}};var Or,Sr,qr={parse:function(t,e){var n=this;this.cond=new Ge(t.args,this.liquid),this.cases=[],this.elseTemplates=[];var i=[],r=this.liquid.parser.parseStream(e).on("tag:when",function(t){i=[];for(var e=new je(t.args,n.liquid.options.operatorsTrie);!e.end();){var r=e.readValue();r&&n.cases.push({val:r,templates:i}),e.readTo(",")}}).on("tag:else",function(){return i=n.elseTemplates}).on("tag:endcase",function(){return r.stop()}).on("template",function(t){return i.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});r.start()},render:function(e,r){var n,i,s,o,a,u,c,l,h;return S(this,function(t){switch(t.label){case 0:return n=this.liquid.renderer,s=f,[4,this.cond.value(e,e.opts.lenientIf)];case 1:i=s.apply(void 0,[t.sent()]),t.label=2;case 2:t.trys.push([2,7,8,9]),o=q(this.cases),a=o.next(),t.label=3;case 3:return a.done?[3,6]:(u=a.value,Ve(u.val,e,e.opts.lenientIf)!==i?[3,5]:[4,n.renderTemplates(u.templates,e,r)]);case 4:return t.sent(),[2];case 5:return a=o.next(),[3,3];case 6:return[3,9];case 7:return c=t.sent(),l={error:c},[3,9];case 8:try{a&&!a.done&&(h=o.return)&&h.call(o)}finally{if(l)throw l.error}return[7];case 9:return[4,n.renderTemplates(this.elseTemplates,e,r)];case 10:return t.sent(),[2]}})}},Er={parse:function(t,e){var r=this.liquid.parser.parseStream(e);r.on("token",function(t){"endcomment"===t.name&&r.stop()}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")}),r.start()}};(Sr=Or=Or||{})[Sr.OUTPUT=0]="OUTPUT",Sr[Sr.STORE=1]="STORE";var Rr,Lr=Or,Fr={parse:function(t){var e=t.args,r=new je(e,this.liquid.options.operatorsTrie);this.file=this.liquid.options.dynamicPartials?r.readValue():r.readFileName(),le(this.file,function(){return'illegal argument "'+t.args+'"'});var n=r.p;"with"===r.readIdentifier().content?(r.skipBlank(),":"!==r.peek()?this.withVar=r.readValue():r.p=n):r.p=n,this.hash=new Je(r.remaining())},render:function(e,r){var n,i,s,o,a,u,c,l,h,p,f,d;return S(this,function(t){switch(t.label){case 0:return i=(n=this).liquid,s=n.hash,o=n.withVar,a=n.file,u=i.renderer,e.opts.dynamicPartials?Tt(a)?[4,u.renderTemplates(i.parse(_e(a)),e)]:[3,2]:[3,5];case 1:return h=t.sent(),[3,4];case 2:return[4,Ve(a,e)];case 3:h=t.sent(),t.label=4;case 4:return l=h,[3,6];case 5:l=a.getText(),t.label=6;case 6:return le(c=l,function(){return'illegal filename "'+a.getText()+'":"'+c+'"'}),p=e.saveRegister("blocks","blockMode"),e.setRegister("blocks",{}),e.setRegister("blockMode",Lr.OUTPUT),[4,s.render(e)];case 7:return f=t.sent(),o&&(f[c]=Ve(o,e)),[4,i._parseFile(c,e.opts,e.sync)];case 8:return d=t.sent(),e.push(f),[4,u.renderTemplates(d,e,r)];case 9:return t.sent(),e.pop(),e.restoreRegister(p),[2]}})}},Mr={parse:function(t){var e=t.args,r=new je(e,this.liquid.options.operatorsTrie);for(this.file=this.liquid.options.dynamicPartials?r.readValue():r.readFileName(),le(this.file,function(){return'illegal argument "'+t.args+'"'});!r.end();){r.skipBlank();var n=r.p,i=r.readIdentifier();if(("with"===i.content||"for"===i.content)&&(r.skipBlank(),":"!==r.peek())){var s=r.readValue();if(s){var o=r.p,a=void 0;"as"===r.readIdentifier().content?a=r.readIdentifier():r.p=o,this[i.content]={value:s,alias:a&&a.content},r.skipBlank(),","===r.peek()&&r.advance();continue}}r.p=n;break}this.hash=new Je(r.remaining())},render:function(e,r){var n,i,s,o,a,u,c,l,h,p,f,d,v,g,y,m,w,T,b,k,x,O;return S(this,function(t){switch(t.label){case 0:return i=(n=this).liquid,s=n.file,o=n.hash,a=i.renderer,e.opts.dynamicPartials?Tt(s)?[4,a.renderTemplates(i.parse(_e(s)),e)]:[3,2]:[3,4];case 1:return l=t.sent(),[3,3];case 2:l=Ve(s,e),t.label=3;case 3:return c=l,[3,5];case 4:c=s.getText(),t.label=5;case 5:return le(u=c,function(){return'illegal filename "'+s.getText()+'":"'+u+'"'}),h=new ft({},e.opts,e.sync),[4,o.render(e)];case 6:if(p=t.sent(),this.with&&(f=this.with,v=f.value,g=f.alias,p[g||u]=Ve(v,e)),h.push(p),!this.for)return[3,16];d=this.for,v=d.value,g=d.alias,y=yr(y=Ve(v,e)),p.forloop=new Tr(y.length),t.label=7;case 7:t.trys.push([7,13,14,15]),m=q(y),w=m.next(),t.label=8;case 8:return w.done?[3,12]:(T=w.value,p[g]=T,[4,i._parseFile(u,h.opts,h.sync)]);case 9:return k=t.sent(),[4,a.renderTemplates(k,h,r)];case 10:t.sent(),p.forloop.next(),t.label=11;case 11:return w=m.next(),[3,8];case 12:return[3,15];case 13:return b=t.sent(),x={error:b},[3,15];case 14:try{w&&!w.done&&(O=m.return)&&O.call(m)}finally{if(x)throw x.error}return[7];case 15:return[3,19];case 16:return[4,i._parseFile(u,h.opts,h.sync)];case 17:return k=t.sent(),[4,a.renderTemplates(k,h,r)];case 18:t.sent(),t.label=19;case 19:return[2]}})}},Dr={parse:function(t){var e=new je(t.args,this.liquid.options.operatorsTrie);this.variable=e.readIdentifier().content},render:function(t,e){var r=t.environments;l(r[this.variable])||(r[this.variable]=0),e.write(c(--r[this.variable]))}},Nr={parse:function(t){var e=new je(t.args,this.liquid.options.operatorsTrie),r=e.readValue();for(e.skipBlank(),this.candidates=[],r&&(":"===e.peek()?(this.group=r,e.advance()):this.candidates.push(r));!e.end();){var n=e.readValue();n&&this.candidates.push(n),e.readTo(",")}le(this.candidates.length,function(){return"empty candidates: "+t.getText()})},render:function(t,e){var r="cycle:"+Ve(this.group,t)+":"+this.candidates.join(","),n=t.getRegister("cycle"),i=n[r];void 0===i&&(i=n[r]=0);var s=this.candidates[i];i=(i+1)%this.candidates.length,n[r]=i;var o=Ve(s,t);e.write(o)}},Pr={parse:function(t,e){var r,n=this;this.branches=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){return n.branches.push({cond:new Ge(t.args,n.liquid),templates:r=[]})}).on("tag:elsif",function(t){n.branches.push({cond:new Ge(t.args,n.liquid),templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endif",function(){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});i.start()},render:function(e,r){var n,i,s,o,a,u,c;return S(this,function(t){switch(t.label){case 0:n=this.liquid.renderer,t.label=1;case 1:t.trys.push([1,7,8,9]),i=q(this.branches),s=i.next(),t.label=2;case 2:return s.done?[3,6]:[4,(o=s.value).cond.value(e,e.opts.lenientIf)];case 3:return P(t.sent(),e)?[4,n.renderTemplates(o.templates,e,r)]:[3,5];case 4:return t.sent(),[2];case 5:return s=i.next(),[3,2];case 6:return[3,9];case 7:return a=t.sent(),u={error:a},[3,9];case 8:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 9:return[4,n.renderTemplates(this.elseTemplates,e,r)];case 10:return t.sent(),[2]}})}},Ar={parse:function(t){var e=new je(t.args,this.liquid.options.operatorsTrie);this.variable=e.readIdentifier().content},render:function(t,e){var r=t.environments;l(r[this.variable])||(r[this.variable]=0);var n=r[this.variable];r[this.variable]++,e.write(c(n))}},Ir={parse:function(t,e){var r=new je(t.args,this.liquid.options.operatorsTrie),n=this.liquid.options.dynamicPartials?r.readValue():r.readFileName();le(n,function(){return'illegal argument "'+t.args+'"'}),this.file=n,this.hash=new Je(r.remaining()),this.tpls=this.liquid.parser.parse(e)},render:function(e,r){var n,i,s,o,a,u,c,l,h,p,f,d,v,g,y;return S(this,function(t){switch(t.label){case 0:return i=(n=this).liquid,s=n.hash,o=n.file,a=i.renderer,"none"!==o.getText()?[3,2]:(e.setRegister("blockMode",Lr.OUTPUT),[4,a.renderTemplates(this.tpls,e)]);case 1:return u=t.sent(),r.write(u),[2];case 2:return e.opts.dynamicPartials?Tt(o)?[4,a.renderTemplates(i.parse(_e(o)),e)]:[3,4]:[3,6];case 3:return h=t.sent(),[3,5];case 4:h=Ve(this.file,e),t.label=5;case 5:return l=h,[3,7];case 6:l=o.getText(),t.label=7;case 7:return le(c=l,function(){return'file "'+o.getText()+'"("'+c+'") not available'}),[4,i._parseFile(c,e.opts,e.sync)];case 8:return p=t.sent(),e.setRegister("blockMode",Lr.STORE),[4,a.renderTemplates(this.tpls,e)];case 9:return f=t.sent(),void 0===(d=e.getRegister("blocks"))[""]&&(d[""]=function(){return f}),e.setRegister("blockMode",Lr.OUTPUT),g=(v=e).push,[4,s.render(e)];case 10:return g.apply(v,[t.sent()]),[4,a.renderTemplates(p,e)];case 11:return y=t.sent(),e.pop(),r.write(y),[2]}})}},Vr=(t(_r,Rr=i),_r.prototype.super=function(){return this.superBlockRender()},_r);function _r(t){void 0===t&&(t=function(){return""});var e=Rr.call(this)||this;return e.superBlockRender=t,e}var jr,Br={parse:function(t,e){var r=this,n=/\w+/.exec(t.args);this.block=n?n[0]:"",this.tpls=[];var i=this.liquid.parser.parseStream(e).on("tag:endblock",function(){return i.stop()}).on("template",function(t){return r.tpls.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});i.start()},render:function(e,r){var n;return S(this,function(t){switch(t.label){case 0:return n=this.getBlockRender(e),[4,this.emitHTML(e,r,n)];case 1:return t.sent(),[2]}})},getBlockRender:function(n){function e(e){var r;return S(this,function(t){switch(t.label){case 0:return n.push({block:e}),[4,i.renderer.renderTemplates(s,n)];case 1:return r=t.sent(),n.pop(),[2,r]}})}var i=this.liquid,s=this.tpls,r=n.getRegister("blocks")[this.block];return r?function(t){return r(new Vr(function(){return e(t)}))}:e},emitHTML:function(e,r,n){var i,s;return S(this,function(t){switch(t.label){case 0:return e.getRegister("blockMode",Lr.OUTPUT)!==Lr.STORE?[3,1]:(e.getRegister("blocks")[this.block]=n,[3,3]);case 1:return s=(i=r).write,[4,n(new Vr)];case 2:s.apply(i,[t.sent()]),t.label=3;case 3:return[2]}})}},zr={parse:function(t,e){var r=this;this.tokens=[];var n=this.liquid.parser.parseStream(e);n.on("token",function(t){"endraw"===t.name?n.stop():r.tokens.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")}),n.start()},render:function(){return this.tokens.map(function(t){return t.getText()}).join("")}},Cr=(t(Hr,jr=Tr),Hr.prototype.row=function(){return Math.floor(this.i/this.cols)+1},Hr.prototype.col0=function(){return this.i%this.cols},Hr.prototype.col=function(){return this.col0()+1},Hr.prototype.col_first=function(){return 0===this.col0()},Hr.prototype.col_last=function(){return this.col()===this.cols},Hr);function Hr(t,e){var r=jr.call(this,t)||this;return r.length=t,r.cols=e,r}var Kr={assign:gr,for:kr,capture:xr,case:qr,comment:Er,include:Fr,render:Mr,decrement:Dr,increment:Ar,cycle:Nr,if:Pr,layout:Ir,block:Br,raw:zr,tablerow:{parse:function(t,e){var r=this,n=new je(t.args,this.liquid.options.operatorsTrie);this.variable=n.readIdentifier(),n.skipBlank();var i,s=n.readIdentifier();le(s&&"in"===s.content,function(){return"illegal tag: "+t.getText()}),this.collection=n.readValue(),this.hash=new Je(n.remaining()),this.templates=[];var o=this.liquid.parser.parseStream(e).on("start",function(){return i=r.templates}).on("tag:endtablerow",function(){return o.stop()}).on("template",function(t){return i.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});o.start()},render:function(e,r){var n,i,s,o,a,u,c,l,h,p;return S(this,function(t){switch(t.label){case 0:return i=yr,[4,Ve(this.collection,e)];case 1:return n=i.apply(void 0,[t.sent()]),[4,this.hash.render(e)];case 2:s=t.sent(),o=s.offset||0,a=void 0===s.limit?n.length:s.limit,n=n.slice(o,o+a),u=s.cols||n.length,c=this.liquid.renderer,l=new Cr(n.length,u),h={tablerowloop:l},e.push(h),p=0,t.label=3;case 3:return p<n.length?(h[this.variable.content]=n[p],0===l.col0()&&(1!==l.row()&&r.write("</tr>"),r.write('<tr class="row'+l.row()+'">')),r.write('<td class="col'+l.col()+'">'),[4,c.renderTemplates(this.templates,e,r)]):[3,6];case 4:t.sent(),r.write("</td>"),t.label=5;case 5:return p++,l.next(),[3,3];case 6:return n.length&&r.write("</tr>"),e.pop(),[2]}})}},unless:{parse:function(t,e){var r,n=this;this.templates=[],this.branches=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){r=n.templates,n.cond=new Ge(t.args,n.liquid)}).on("tag:elsif",function(t){n.branches.push({cond:new Ge(t.args,n.liquid),templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.getText()+" not closed")});i.start()},render:function(e,r){var n,i,s,o,a,u,c;return S(this,function(t){switch(t.label){case 0:return n=this.liquid.renderer,[4,this.cond.value(e,e.opts.lenientIf)];case 1:return A(t.sent(),e)?[4,n.renderTemplates(this.templates,e,r)]:[3,3];case 2:return t.sent(),[2];case 3:t.trys.push([3,9,10,11]),i=q(this.branches),s=i.next(),t.label=4;case 4:return s.done?[3,8]:[4,(o=s.value).cond.value(e,e.opts.lenientIf)];case 5:return P(t.sent(),e)?[4,n.renderTemplates(o.templates,e,r)]:[3,7];case 6:return t.sent(),[2];case 7:return s=i.next(),[3,4];case 8:return[3,11];case 9:return a=t.sent(),u={error:a},[3,11];case 10:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 11:return[4,n.renderTemplates(this.elseTemplates,e,r)];case 12:return t.sent(),[2]}})}},break:{render:function(t,e){e.break=!0}},continue:{render:function(t,e){e.continue=!0}}},Ur={"&":"&","<":"<",">":">",'"':""","'":"'"},Qr={"&":"&","<":"<",">":">",""":'"',"'":"'"};function Wr(t){return c(t).replace(/&|<|>|"|'/g,function(t){return Ur[t]})}var Jr=Math.abs,Yr=Math.max,Zr=Math.min,$r=Math.ceil,Gr=Math.floor;var Xr=/%([-_0^#:]+)?(\d+)?([EO])?(.)/,tn=["January","February","March","April","May","June","July","August","September","October","November","December"],en=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],rn=tn.map(on),nn=en.map(on),sn={1:"st",2:"nd",3:"rd",default:"th"};function on(t){return t.slice(0,3)}function an(t){for(var e=0,r=0;r<t.getMonth();++r)e+=[31,function(t){var e=t.getFullYear();return!(0!=(3&e)||!(e%100||e%400==0&&e))}(t)?29:28,31,30,31,30,31,31,30,31,30,31][r];return e+t.getDate()}function un(t,e){var r=an(t)+(e-t.getDay()),n=7-new Date(t.getFullYear(),0,1).getDay()+e;return String(Math.floor((r-n)/7)+1)}var cn={d:2,e:2,H:2,I:2,j:3,k:2,l:2,L:3,m:2,M:2,S:2,U:2,W:2},ln={a:" ",A:" ",b:" ",B:" ",c:" ",e:" ",k:" ",l:" ",p:" ",P:" "},hn={a:function(t){return nn[t.getDay()]},A:function(t){return en[t.getDay()]},b:function(t){return rn[t.getMonth()]},B:function(t){return tn[t.getMonth()]},c:function(t){return t.toLocaleString()},C:function(t){return function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}(t)},d:function(t){return t.getDate()},e:function(t)