!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Liquid=t()}(this,function(){"use strict";var F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q=function(e){return function(){var u=e.apply(this,arguments);return new Promise(function(o,a){return function t(e,r){try{var n=u[e](r),i=n.value}catch(e){return void a(e)}if(!n.done)return Promise.resolve(i).then(function(e){t("next",e)},function(e){t("throw",e)});o(i)}("next")})}};!function(e){var s,t=Object.prototype,c=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag",a="object"===("undefined"==typeof module?"undefined":F(module)),u=e.regeneratorRuntime;if(u)a&&(module.exports=u);else{(u=e.regeneratorRuntime=a?module.exports:{}).wrap=w;var p="suspendedStart",f="suspendedYield",h="executing",g="completed",d={},l={};l[i]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(O([])));m&&m!==t&&c.call(m,i)&&(l=m);var y=E.prototype=b.prototype=Object.create(l);k.prototype=y.constructor=E,E.constructor=k,E[o]=k.displayName="GeneratorFunction",u.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},u.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(y),e},u.awrap=function(e){return{__await:e}},R(T.prototype),T.prototype[n]=function(){return this},u.AsyncIterator=T,u.async=function(e,t,r,n){var i=new T(w(e,t,r,n));return u.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},R(y),y[o]="Generator",y[i]=function(){return this},y.toString=function(){return"[object Generator]"},u.keys=function(r){var n=[];for(var e in r)n.push(e);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},u.values=O,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(L),!e)for(var t in this)"t"===t.charAt(0)&&c.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=s)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return o.type="throw",o.arg=r,n.next=e,t&&(n.method="next",n.arg=s),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var i=this.tryEntries[t],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=c.call(i,"catchLoc"),u=c.call(i,"finallyLoc");if(a&&u){if(this.prev=|<|>|\s+contains\s+/];function A(){this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function D(e,t){A.call(this),this.input=t.input,this.line=t.line,this.file=t.file;var r,i,o,n,a,u=(r=t.input,i=t.line,o=r.split("\n"),n=Math.max(i-2,1),a=Math.min(i+3,o.length),function(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],i=e;i> ":" ",(t=e,r=a,n=t+"",Array((r+"").length-n.length).join(" ")+n),"| ",o[e-1]].join("");var t,r,n}).join("\n"));this.message=function(e,t){e=e||"",t.file&&(e+=", file:"+t.file);t.line&&(e+=", line:"+t.line);return e}(e.message,t),this.stack=u+"\n"+(this.stack||this.message)+(e.stack?"\nFrom "+e.stack:"")}function I(e,t){D.call(this,{message:e},t)}function q(e,t){m(this,e),this.originalError=e,D.call(this,e,t)}function C(e,t){if(e instanceof C)return e;m(this,e),this.originalError=e,D.call(this,e,t.token)}function V(e){A.call(this),this.message=e+""}function N(e){A.call(this),this.message=e+""}function ue(e,t){if(!e)throw new N(t=t||"expect "+e+" to be true")}(I.prototype=ee(Error.prototype)).constructor=I,(q.prototype=ee(Error.prototype)).constructor=q,(C.prototype=ee(Error.prototype)).constructor=C,(V.prototype=ee(Error.prototype)).constructor=V,(N.prototype=ee(Error.prototype)).constructor=N;var Y={getAll:function(){return this.contexts.reduce(function(e,t){return m(e,t)},ee(null))},get:function(e){var r=this,t=this.propertyAccessSeq(e),n=this.findContextFor(t[0])||y(this.contexts);return t.reduce(function(e,t){return r.readProperty(e,t)},n)},set:function(e,r){var n=this.propertyAccessSeq(e),i=this.findContextFor(n[0])||y(this.contexts);n.some(function(e,t){return!re(i)||(t===n.length-1?(i[e]=r,!0):(void 0===i[e]&&(i[e]={}),void(i=i[e])))})},unshift:function(e){return this.contexts.unshift(e)},push:function(e){return this.contexts.push(e)},pop:function(t){if(!arguments.length)return this.contexts.pop();var e=this.contexts.findIndex(function(e){return e===t});if(-1===e)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(e,1)[0]},findContextFor:function(e,t){t=t||function(){return!0};for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(t(n)&&e in n)return n}return null},readProperty:function(e,t){var r,n=void 0;if(u(e)?n=void 0:(e=function(e){if(o(e.to_liquid))return e.to_liquid();if(o(e.toLiquid))return e.toLiquid();return e}(e),n="size"===t?u((r=e).size)&&(te(r)||Z(r))?r.length:r.size:e[t],o(e.liquid_method_missing)&&(n=e.liquid_method_missing(t))),u(n)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+t);return n},propertyAccessSeq:function(e){e=String(e);for(var t,r=[],n="",i=void 0,o=0;oh&&g.push(v(h,t.index)),g.push(t[1]?d(t[1],t[2].trim(),t.index):(u=t[3],s=t[4].trim(),c=t.index,{type:"value",line:f.get(c),trim_left:"{{-"===u.slice(0,3),trim_right:"-}}"===u.slice(-3),raw:u,value:s,input:o,file:a}));return o.length>h&&g.push(v(h,o.length)),function(a,u){u=m({greedy:!0},u);var s=!1;a.forEach(function(e,t){var r,n,i,o;i=e,o=u,!s&&("tag"===i.type?i.trim_left||o.trim_tag_left:"value"===i.type?i.trim_left||o.trim_value_left:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/\s+$/g:/[\t\r ]*$/g;e.value=e.value.replace(r,"")}}(a[t-1],u.greedy),"tag"===e.type&&"raw"===e.name&&(s=!0),"tag"===e.type&&"endraw"===e.name&&(s=!1),r=e,n=u,!s&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/^\s+/g:/^[\t\r ]*\n?/g;e.value=e.value.replace(r,"")}}(a[t+1],u.greedy)})}(g,e),g;function d(e,t,r){var n=t.match(x),i={type:"tag",indent:p,line:f.get(r),trim_left:"{%-"===e.slice(0,3),trim_right:"-%}"===e.slice(-3),raw:e,value:t,input:o,file:a};if(!n)throw new I("illegal tag syntax",i);return i.name=n[1],i.args=n[2],i}function v(e,t){var r=o.slice(e,t);return p=y(r.split("\n")).length,{type:"html",raw:r,value:r}}}var le,pe=(le=ge,{"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},">":function(e,t){return null!==e&&null!==t&&t=":function(e,t){return null!==e&&null!==t&&t<=e},"<=":function(e,t){return null!==e&&null!==t&&e<=t},contains:function(e,t){return!!e&&"function"==typeof e.indexOf&&-1"),c+=''),c+='',i.push(t),e.next=7,U.renderer.renderTemplates(l.templates,i);case 7:return c+=e.sent,c+="",i.pop(t),e.abrupt("return",c);case 11:case"end":return e.stop()}},e,l)}));return function(e,t){return r.apply(this,arguments)}}());case 10:return 0"),e.abrupt("return",c);case 12:case"end":return e.stop()}},e,this)})),function(e,t){return J.apply(this,arguments)})}),K=t,(X=e).registerTag("unless",{parse:function(t,e){var r=this;this.templates=[],this.elseTemplates=[];var n=void 0,i=X.parser.parseStream(e).on("start",function(e){n=r.templates,r.cond=t.args}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endunless",function(e){return i.stop()}).on("template",function(e){return n.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(e,t){var r=K.evalExp(this.cond,e);return K.isFalsy(r)?X.renderer.renderTemplates(this.templates,e):X.renderer.renderTemplates(this.elseTemplates,e)}})}var Te=["January","February","March","April","May","June","July","August","September","October","November","December"],Se=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_e=Te.map(Oe),Le=Se.map(Oe),je={1:"st",2:"nd",3:"rd",default:"th"};function Oe(e){return e.slice(0,3)}var Me={daysInMonth:function(e){return[31,Me.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r":">",'"':""","'":"'"},De={"&":"&","<":"<",">":">",""":'"',"'":"'"},Ie={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return Ve(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},concat:function(e,t){return Array.prototype.concat.call(e,t)},date:function(e,t){var r,n=e;return"now"===e?n=new Date:Z(e)&&(n=new Date(e)),(r=n)instanceof Date&&!isNaN(r.getTime())?function(e,t){for(var r="",n=t;;){var i=/%./g,o=i.exec(n);if(!o)return r+n;r+=n.slice(0,i.lastIndex-2),n=n.slice(i.lastIndex);var a=o[0].charAt(1),u=Pe[a];r+=u?u.call(this,e):"%"+a}}(n,t):e},default:function(e,t){return ge(e)?e:t},divided_by:function(e,t){return e/t},downcase:function(e){return e.toLowerCase()},escape:qe,escape_once:function(e){return qe(Ve(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return De[e]}))},first:function(e){return e[0]},floor:function(e){return Math.floor(e)},join:function(e,t){return e.join(void 0===t?" ":t)},last:function(e){return y(e)},lstrip:function(e){return Ve(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:Ne(function(e,t){return e-t}),modulo:Ne(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"
")},plus:Ne(function(e,t){return Number(e)+Number(t)}),prepend:function(e,t){return t+e},remove:function(e,t){return e.split(t).join("")},remove_first:function(e,t){return e.replace(t,"")},replace:function(e,t,r){return Ve(e).split(t).join(r)},replace_first:function(e,t,r){return Ve(e).replace(t,r)},reverse:function(e){return e.reverse()},round:function(e,t){var r=Math.pow(10,t||0);return Math.round(e*r,t)/r},rstrip:function(e){return Ve(e).replace(/\s+$/,"")},size:function(e){return e.length},slice:function(e,t,r){return void 0===r&&(r=1),e.slice(t,t+r)},sort:function(e,t){return e.sort(t)},split:function(e,t){return Ve(e).split(t)},strip:function(e){return Ve(e).trim()},strip_html:function(e){return Ve(e).replace(/|||<.*?>/g,"")},strip_newlines:function(e){return Ve(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return r=void 0===r?"...":r,t=t||16,(e=Ve(e)).length<=t?e:e.substr(0,t-r.length)+r},truncatewords:function(e,t,r){void 0===r&&(r="...");var n=e.split(" "),i=n.slice(0,t).join(" ");return n.length>t&&(i+=r),i},uniq:function(e){var t={};return(e||[]).filter(function(e){return!t.hasOwnProperty(e)&&(t[e]=!0)})},upcase:function(e){return Ve(e).toUpperCase()},url_decode:function(e){return e.split("+").map(decodeURIComponent).join(" ")},url_encode:function(e){return e.split(" ").map(encodeURIComponent).join("+")}};function qe(e){return Ve(e).replace(/&|<|>|"|'/g,function(e){return Ae[e]})}function Ce(e){var t=(e+"").split(".");return 1