!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Liquid=e()}(this,function(){"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 e(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function B(o,s,u,a){return new(u||(u=Promise))(function(t,e){function r(t){try{i(a.next(t))}catch(t){e(t)}}function n(t){try{i(a.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(r,n)}i((a=a.apply(o,s||[])).next())})}function U(r,n){var i,o,s,t,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[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(;u;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]=|<|>|\s+contains\s+/];function q(){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}var C=function(){function t(t,e){this.input=e.input,this.line=e.line,this.file=e.file,this.originalError=t,this.token=e}return t.prototype.captureStackTrace=function(t){this.name=t.constructor.name,q.call(t);var e,s,u,r,a,n=this.originalError,i=(e=this.input,s=this.line,u=e.split("\n"),r=Math.max(s-2,1),a=Math.min(s+3,u.length),function(t,e,r){1===arguments.length&&(e=t,t=0),r=r||1;for(var n=[],i=t;i> ":" ",i=(e=String(a).length,r=t,r=String(r),Array(e-r.length).join(" ")+r),o=u[t-1];return""+n+i+"| "+o}).join("\n"));this.message=function(t,e){t=t||"",e.file&&(t+=", file:"+e.file);e.line&&(t+=", line:"+e.line);return t}(n.message,this.token),this.stack=i+"\n"+(this.stack||this.message)+(n.stack?"\nFrom "+n.stack:"")},t}(),F=function(n){function t(t,e){var r=n.call(this,{message:t},e)||this;return n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);F.prototype=J(Error.prototype),F.prototype.constructor=F;var P=function(n){function t(t,e){var r=n.call(this,t,e)||this;return m(r,t),n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);P.prototype=J(Error.prototype),P.prototype.constructor=P;var L=function(n){function t(t,e){var r=n.call(this,t,e.token)||this;return m(r,t),n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);L.prototype=J(Error.prototype),L.prototype.constructor=L;var I=function(t){q.call(this),this.message=t+""};I.prototype=J(Error.prototype),I.prototype.constructor=I;var V=function(t){q.call(this),this.message=t+""};function et(t,e){if(!t)throw new V(e=e||"expect "+t+" to be true")}V.prototype=J(Error.prototype),V.prototype.constructor=V;var $=function(){function t(t,e){void 0===t&&(t={});this.opts=m({dynamicPartials:!0,strict_variables:!1,strict_filters:!1,blocks:{},root:[]},e),this.contexts=[t||{}]}return t.prototype.getAll=function(){return this.contexts.reduce(function(t,e){return m(t,e)},J(null))},t.prototype.get=function(t){var r=this,e=this.propertyAccessSeq(t),n=this.findContextFor(e[0])||y(this.contexts);return e.reduce(function(t,e){return r.readProperty(t,e)},n)},t.prototype.set=function(t,r){var n=this.propertyAccessSeq(t),i=this.findContextFor(n[0])||y(this.contexts);n.some(function(t,e){return!X(i)||(e===n.length-1?(i[t]=r,!0):(void 0===i[t]&&(i[t]={}),void(i=i[t])))})},t.prototype.unshift=function(t){return this.contexts.unshift(t)},t.prototype.push=function(t){return this.contexts.push(t)},t.prototype.pop=function(e){if(!arguments.length)return this.contexts.pop();var t=this.contexts.findIndex(function(t){return t===e});if(-1===t)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(t,1)[0]},t.prototype.findContextFor=function(t,e){void 0===e&&(e=function(t){return!0});for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(e(n)&&t in n)return n}return null},t.prototype.readProperty=function(t,e){var r,n;if(a(t)?r=void 0:(t=function(t){if(s(t.to_liquid))return t.to_liquid();if(s(t.toLiquid))return t.toLiquid();return t}(t),r="size"===e?a((n=t).size)&&(G(n)||W(n))?n.length:n.size:t[e],s(t.liquid_method_missing)&&(r=t.liquid_method_missing(e))),a(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+e);return r},t.prototype.propertyAccessSeq=function(t){t=String(t);for(var e,r,n=[],i="",o=0;of&&h.push(v(f,d.index)),h.push(d[1]?g(d[1],d[2].trim(),d.index):(e=d[3],u=d[4].trim(),a=d.index,{type:"value",line:p.get(a),trim_left:"{{-"===e.slice(0,3),trim_right:"-}}"===e.slice(-3),raw:e,value:u,input:o,file:s}));return o.length>f&&h.push(v(f,o.length)),function(s,u){u=m({greedy:!0},u);var a=!1;s.forEach(function(t,e){var r,n,i,o;i=t,o=u,!a&&("tag"===i.type?i.trim_left||o.trim_tag_left:"value"===i.type?i.trim_left||o.trim_value_left:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/\s+$/g:/[\t\r ]*$/g;t.value=t.value.replace(r,"")}}(s[e-1],u.greedy),"tag"===t.type&&"raw"===t.name&&(a=!0),"tag"===t.type&&"endraw"===t.name&&(a=!1),r=t,n=u,!a&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/^\s+/g:/^[\t\r ]*\n?/g;t.value=t.value.replace(r,"")}}(s[e+1],u.greedy)})}(h,t),h;function g(t,e,r){var n=e.match(b),i={type:"tag",indent:l,line:p.get(r),trim_left:"{%-"===t.slice(0,3),trim_right:"-%}"===t.slice(-3),raw:t,value:e,input:o,file:s};if(!n)throw new F("illegal tag syntax",i);return i.name=n[1],i.args=n[2],i}function v(t,e){var r=o.slice(t,e);return l=y(r.split("\n")).length,{type:"html",raw:r,value:r}}}var z,rt=(z=ot,{"==":function(t,e){return t===e},"!=":function(t,e){return t!==e},">":function(t,e){return null!==t&&null!==e&&e=":function(t,e){return null!==t&&null!==e&&e<=t},"<=":function(t,e){return null!==t&&null!==e&&t<=e},contains:function(t,e){return!!t&&"function"==typeof t.indexOf&&-1"),u+=''),u+='',c.push(n),r=u,[4,$.renderer.renderTemplates(this.templates,c)];case 1:return u=r+t.sent(),u+="",c.pop(n),[2,u]}})})})];case 1:return t.sent(),0"),[2,u]}})})}}),z=e,(N=t).registerTag("unless",{parse:function(e,t){var r,n=this;this.templates=[],this.elseTemplates=[];var i=N.parser.parseStream(t).on("start",function(t){r=n.templates,n.cond=e.args}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(t){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){var r=z.evalExp(this.cond,t);return z.isFalsy(r)?N.renderer.renderTemplates(this.templates,t):N.renderer.renderTemplates(this.elseTemplates,t)}})}var dt=["January","February","March","April","May","June","July","August","September","October","November","December"],gt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],vt=dt.map(wt),mt=gt.map(wt),yt={1:"st",2:"nd",3:"rd",default:"th"};function wt(t){return t.slice(0,3)}var bt={daysInMonth:function(t){return[31,bt.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(t){for(var e=0,r=0;r":">",'"':""","'":"'"},kt={"&":"&","<":"<",">":">",""":'"',"'":"'"},St={abs:function(t){return Math.abs(t)},append:function(t,e){return t+e},capitalize:function(t){return Mt(t).charAt(0).toUpperCase()+t.slice(1)},ceil:function(t){return Math.ceil(t)},concat:function(t,e){return Array.prototype.concat.call(t,e)},date:function(t,e){var r,n=t;return"now"===t?n=new Date:W(t)&&(n=new Date(t)),(r=n)instanceof Date&&!isNaN(r.getTime())?function(t,e){for(var r="",n=e;;){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 s=o[0].charAt(1),u=Tt[s];r+=u?u.call(this,t):"%"+s}}(n,e):t},default:function(t,e){return ot(t)?t:e},divided_by:function(t,e){return t/e},downcase:function(t){return t.toLowerCase()},escape:_t,escape_once:function(t){return _t(Mt(t).replace(/&(amp|lt|gt|#34|#39);/g,function(t){return kt[t]}))},first:function(t){return t[0]},floor:function(t){return Math.floor(t)},join:function(t,e){return t.join(void 0===e?" ":e)},last:function(t){return y(t)},lstrip:function(t){return Mt(t).replace(/^\s+/,"")},map:function(t,e){return t.map(function(t){return t[e]})},minus:Ot(function(t,e){return t-e}),modulo:Ot(function(t,e){return t%e}),newline_to_br:function(t){return t.replace(/\n/g,"
")},plus:Ot(function(t,e){return Number(t)+Number(e)}),prepend:function(t,e){return e+t},remove:function(t,e){return t.split(e).join("")},remove_first:function(t,e){return t.replace(e,"")},replace:function(t,e,r){return Mt(t).split(e).join(r)},replace_first:function(t,e,r){return Mt(t).replace(e,r)},reverse:function(t){return t.reverse()},round:function(t,e){var r=Math.pow(10,e||0);return Math.round(t*r,e)/r},rstrip:function(t){return Mt(t).replace(/\s+$/,"")},size:function(t){return t.length},slice:function(t,e,r){return void 0===r&&(r=1),t.slice(e,e+r)},sort:function(t,e){return t.sort(e)},split:function(t,e){return Mt(t).split(e)},strip:function(t){return Mt(t).trim()},strip_html:function(t){return Mt(t).replace(/|||<.*?>/g,"")},strip_newlines:function(t){return Mt(t).replace(/\n/g,"")},times:function(t,e){return t*e},truncate:function(t,e,r){return r=void 0===r?"...":r,e=e||16,(t=Mt(t)).length<=e?t:t.substr(0,e-r.length)+r},truncatewords:function(t,e,r){void 0===r&&(r="...");var n=t.split(" "),i=n.slice(0,e).join(" ");return n.length>e&&(i+=r),i},uniq:function(t){var e={};return(t||[]).filter(function(t){return!e.hasOwnProperty(t)&&(e[t]=!0)})},upcase:function(t){return Mt(t).toUpperCase()},url_decode:function(t){return t.split("+").map(decodeURIComponent).join(" ")},url_encode:function(t){return t.split(" ").map(encodeURIComponent).join("+")}};function _t(t){return Mt(t).replace(/&|<|>|"|'/g,function(t){return Et[t]})}function Rt(t){var e=(t+"").split(".");return 1