/**
 * @preserve Copyright 2012 Twitter, Inc.
 * @license http://www.apache.org/licenses/LICENSE-2.0.txt
 */
var Hogan = {};
(function(e) {
  function t(e, t, n) {
    var r, i;
    return (
      t &&
        typeof t == 'object' &&
        (t[e] != null
          ? (r = t[e])
          : n && t.get && typeof t.get == 'function' && (r = t.get(e))),
      r
    );
  }
  function n(e, t, n, r, i, s) {
    function o() {}
    function u() {}
    (o.prototype = e), (u.prototype = e.subs);
    var a,
      f = new o();
    (f.subs = new u()),
      (f.subsText = {}),
      (f.buf = ''),
      (r = r || {}),
      (f.stackSubs = r),
      (f.subsText = s);
    for (a in t) r[a] || (r[a] = t[a]);
    for (a in r) f.subs[a] = r[a];
    (i = i || {}), (f.stackPartials = i);
    for (a in n) i[a] || (i[a] = n[a]);
    for (a in i) f.partials[a] = i[a];
    return f;
  }
  function f(e) {
    return String(e === null || e === undefined ? '' : e);
  }
  function l(e) {
    return (
      (e = f(e)),
      a.test(e)
        ? e
            .replace(r, '&amp;')
            .replace(i, '&lt;')
            .replace(s, '&gt;')
            .replace(o, '&#39;')
            .replace(u, '&quot;')
        : e
    );
  }
  (e.Template = function(e, t, n, r) {
    (e = e || {}),
      (this.r = e.code || this.r),
      (this.c = n),
      (this.options = r || {}),
      (this.text = t || ''),
      (this.partials = e.partials || {}),
      (this.subs = e.subs || {}),
      (this.buf = '');
  }),
    (e.Template.prototype = {
      r: function(e, t, n) {
        return '';
      },
      v: l,
      t: f,
      render: function(t, n, r) {
        return this.ri([t], n || {}, r);
      },
      ri: function(e, t, n) {
        return this.r(e, t, n);
      },
      ep: function(e, t) {
        var r = this.partials[e],
          i = t[r.name];
        if (r.instance && r.base == i) return r.instance;
        if (typeof i == 'string') {
          if (!this.c) throw new Error('No compiler available.');
          i = this.c.compile(i, this.options);
        }
        if (!i) return null;
        this.partials[e].base = i;
        if (r.subs) {
          t.stackText || (t.stackText = {});
          for (key in r.subs)
            t.stackText[key] ||
              (t.stackText[key] =
                this.activeSub !== undefined && t.stackText[this.activeSub]
                  ? t.stackText[this.activeSub]
                  : this.text);
          i = n(
            i,
            r.subs,
            r.partials,
            this.stackSubs,
            this.stackPartials,
            t.stackText
          );
        }
        return (this.partials[e].instance = i), i;
      },
      rp: function(e, t, n, r) {
        var i = this.ep(e, n);
        return i ? i.ri(t, n, r) : '';
      },
      rs: function(e, t, n) {
        var r = e[e.length - 1];
        if (!c(r)) {
          n(e, t, this);
          return;
        }
        for (var i = 0; i < r.length; i++) e.push(r[i]), n(e, t, this), e.pop();
      },
      s: function(e, t, n, r, i, s, o) {
        var u;
        return c(e) && e.length === 0
          ? !1
          : (typeof e == 'function' && (e = this.ms(e, t, n, r, i, s, o)),
            (u = !!e),
            !r && u && t && t.push(typeof e == 'object' ? e : t[t.length - 1]),
            u);
      },
      d: function(e, n, r, i) {
        var s,
          o = e.split('.'),
          u = this.f(o[0], n, r, i),
          a = this.options.modelGet,
          f = null;
        if (e === '.' && c(n[n.length - 2])) u = n[n.length - 1];
        else
          for (var l = 1; l < o.length; l++)
            (s = t(o[l], u, a)), s != null ? ((f = u), (u = s)) : (u = '');
        return i && !u
          ? !1
          : (!i &&
              typeof u == 'function' &&
              (n.push(f), (u = this.mv(u, n, r)), n.pop()),
            u);
      },
      f: function(e, n, r, i) {
        var s = !1,
          o = null,
          u = !1,
          a = this.options.modelGet;
        for (var f = n.length - 1; f >= 0; f--) {
          (o = n[f]), (s = t(e, o, a));
          if (s != null) {
            u = !0;
            break;
          }
        }
        return u
          ? (!i && typeof s == 'function' && (s = this.mv(s, n, r)), s)
          : i ? !1 : '';
      },
      ls: function(e, t, n, r, i) {
        var s = this.options.delimiters;
        return (
          (this.options.delimiters = i),
          this.b(this.ct(f(e.call(t, r)), t, n)),
          (this.options.delimiters = s),
          !1
        );
      },
      ct: function(e, t, n) {
        if (this.options.disableLambda)
          throw new Error('Lambda features disabled.');
        return this.c.compile(e, this.options).render(t, n);
      },
      b: function(e) {
        this.buf += e;
      },
      fl: function() {
        var e = this.buf;
        return (this.buf = ''), e;
      },
      ms: function(e, t, n, r, i, s, o) {
        var u,
          a = t[t.length - 1],
          f = e.call(a);
        return typeof f == 'function'
          ? r
            ? !0
            : ((u =
                this.activeSub && this.subsText && this.subsText[this.activeSub]
                  ? this.subsText[this.activeSub]
                  : this.text),
              this.ls(f, a, n, u.substring(i, s), o))
          : f;
      },
      mv: function(e, t, n) {
        var r = t[t.length - 1],
          i = e.call(r);
        return typeof i == 'function' ? this.ct(f(i.call(r)), r, n) : i;
      },
      sub: function(e, t, n, r) {
        var i = this.subs[e];
        i && ((this.activeSub = e), i(t, n, this, r), (this.activeSub = !1));
      },
    });
  var r = /&/g,
    i = /</g,
    s = />/g,
    o = /\'/g,
    u = /\"/g,
    a = /[&<>\"\']/,
    c =
      Array.isArray ||
      function(e) {
        return Object.prototype.toString.call(e) === '[object Array]';
      };
})(typeof exports != 'undefined' ? exports : Hogan),
  typeof module != 'undefined' && module.exports && (module.exports = Hogan);
