github.com/hairyhenderson/templater@v3.5.0+incompatible/docs/static/js/application.js (about)

     1  function pegasus(t, e) {
     2      return (
     3          (e = new XMLHttpRequest()),
     4          e.open("GET", t),
     5          (t = []),
     6          (e.onreadystatechange = e.then = function (n, o, i, r) {
     7              if (
     8                  (n && n.call && (t = [, n, o]),
     9                      4 == e.readyState && (i = t[0 | (e.status / 200)]))
    10              ) {
    11                  try {
    12                      r = JSON.parse(e.responseText);
    13                  } catch (s) {
    14                      r = null;
    15                  }
    16                  i(r, e);
    17              }
    18          }),
    19          e.send(),
    20          e
    21      );
    22  }
    23  if (
    24      ("document" in self &&
    25          ("classList" in document.createElement("_")
    26              ? !(function () {
    27                  "use strict";
    28                  var t = document.createElement("_");
    29                  if ((t.classList.add("c1", "c2"), !t.classList.contains("c2"))) {
    30                      var e = function (t) {
    31                          var e = DOMTokenList.prototype[t];
    32                          DOMTokenList.prototype[t] = function (t) {
    33                              var n,
    34                                  o = arguments.length;
    35                              for (n = 0; o > n; n++) (t = arguments[n]), e.call(this, t);
    36                          };
    37                      };
    38                      e("add"), e("remove");
    39                  }
    40                  if ((t.classList.toggle("c3", !1), t.classList.contains("c3"))) {
    41                      var n = DOMTokenList.prototype.toggle;
    42                      DOMTokenList.prototype.toggle = function (t, e) {
    43                          return 1 in arguments && !this.contains(t) == !e
    44                              ? e
    45                              : n.call(this, t);
    46                      };
    47                  }
    48                  t = null;
    49              })()
    50              : !(function (t) {
    51                  "use strict";
    52                  if ("Element" in t) {
    53                      var e = "classList",
    54                          n = "prototype",
    55                          o = t.Element[n],
    56                          i = Object,
    57                          r =
    58                              String[n].trim ||
    59                              function () {
    60                                  return this.replace(/^\s+|\s+$/g, "");
    61                              },
    62                          s =
    63                              Array[n].indexOf ||
    64                              function (t) {
    65                                  for (var e = 0, n = this.length; n > e; e++)
    66                                      if (e in this && this[e] === t) return e;
    67                                  return -1;
    68                              },
    69                          a = function (t, e) {
    70                              (this.name = t),
    71                                  (this.code = DOMException[t]),
    72                                  (this.message = e);
    73                          },
    74                          c = function (t, e) {
    75                              if ("" === e)
    76                                  throw new a(
    77                                      "SYNTAX_ERR",
    78                                      "An invalid or illegal string was specified"
    79                                  );
    80                              if (/\s/.test(e))
    81                                  throw new a(
    82                                      "INVALID_CHARACTER_ERR",
    83                                      "String contains an invalid character"
    84                                  );
    85                              return s.call(t, e);
    86                          },
    87                          l = function (t) {
    88                              for (
    89                                  var e = r.call(t.getAttribute("class") || ""),
    90                                  n = e ? e.split(/\s+/) : [],
    91                                  o = 0,
    92                                  i = n.length;
    93                                  i > o;
    94                                  o++
    95                              )
    96                                  this.push(n[o]);
    97                              this._updateClassName = function () {
    98                                  t.setAttribute("class", this.toString());
    99                              };
   100                          },
   101                          u = (l[n] = []),
   102                          d = function () {
   103                              return new l(this);
   104                          };
   105                      if (
   106                          ((a[n] = Error[n]),
   107                              (u.item = function (t) {
   108                                  return this[t] || null;
   109                              }),
   110                              (u.contains = function (t) {
   111                                  return (t += ""), -1 !== c(this, t);
   112                              }),
   113                              (u.add = function () {
   114                                  var t,
   115                                      e = arguments,
   116                                      n = 0,
   117                                      o = e.length,
   118                                      i = !1;
   119                                  do
   120                                      (t = e[n] + ""),
   121                                          -1 === c(this, t) && (this.push(t), (i = !0));
   122                                  while (++n < o);
   123                                  i && this._updateClassName();
   124                              }),
   125                              (u.remove = function () {
   126                                  var t,
   127                                      e,
   128                                      n = arguments,
   129                                      o = 0,
   130                                      i = n.length,
   131                                      r = !1;
   132                                  do
   133                                      for (t = n[o] + "", e = c(this, t); -1 !== e;)
   134                                          this.splice(e, 1), (r = !0), (e = c(this, t));
   135                                  while (++o < i);
   136                                  r && this._updateClassName();
   137                              }),
   138                              (u.toggle = function (t, e) {
   139                                  t += "";
   140                                  var n = this.contains(t),
   141                                      o = n ? e !== !0 && "remove" : e !== !1 && "add";
   142                                  return o && this[o](t), e === !0 || e === !1 ? e : !n;
   143                              }),
   144                              (u.toString = function () {
   145                                  return this.join(" ");
   146                              }),
   147                              i.defineProperty)
   148                      ) {
   149                          var h = { get: d, enumerable: !0, configurable: !0 };
   150                          try {
   151                              i.defineProperty(o, e, h);
   152                          } catch (f) {
   153                              -2146823252 === f.number &&
   154                                  ((h.enumerable = !1), i.defineProperty(o, e, h));
   155                          }
   156                      } else i[n].__defineGetter__ && o.__defineGetter__(e, d);
   157                  }
   158              })(self)),
   159          (function () {
   160              "use strict";
   161              function t(e, o) {
   162                  function i(t, e) {
   163                      return function () {
   164                          return t.apply(e, arguments);
   165                      };
   166                  }
   167                  var r;
   168                  if (
   169                      ((o = o || {}),
   170                          (this.trackingClick = !1),
   171                          (this.trackingClickStart = 0),
   172                          (this.targetElement = null),
   173                          (this.touchStartX = 0),
   174                          (this.touchStartY = 0),
   175                          (this.lastTouchIdentifier = 0),
   176                          (this.touchBoundary = o.touchBoundary || 10),
   177                          (this.layer = e),
   178                          (this.tapDelay = o.tapDelay || 200),
   179                          (this.tapTimeout = o.tapTimeout || 700),
   180                          !t.notNeeded(e))
   181                  ) {
   182                      for (
   183                          var s = [
   184                              "onMouse",
   185                              "onClick",
   186                              "onTouchStart",
   187                              "onTouchMove",
   188                              "onTouchEnd",
   189                              "onTouchCancel"
   190                          ],
   191                          a = this,
   192                          c = 0,
   193                          l = s.length;
   194                          l > c;
   195                          c++
   196                      )
   197                          a[s[c]] = i(a[s[c]], a);
   198                      n &&
   199                          (e.addEventListener("mouseover", this.onMouse, !0),
   200                              e.addEventListener("mousedown", this.onMouse, !0),
   201                              e.addEventListener("mouseup", this.onMouse, !0)),
   202                          e.addEventListener("click", this.onClick, !0),
   203                          e.addEventListener("touchstart", this.onTouchStart, !1),
   204                          e.addEventListener("touchmove", this.onTouchMove, !1),
   205                          e.addEventListener("touchend", this.onTouchEnd, !1),
   206                          e.addEventListener("touchcancel", this.onTouchCancel, !1),
   207                          Event.prototype.stopImmediatePropagation ||
   208                          ((e.removeEventListener = function (t, n, o) {
   209                              var i = Node.prototype.removeEventListener;
   210                              "click" === t
   211                                  ? i.call(e, t, n.hijacked || n, o)
   212                                  : i.call(e, t, n, o);
   213                          }),
   214                              (e.addEventListener = function (t, n, o) {
   215                                  var i = Node.prototype.addEventListener;
   216                                  "click" === t
   217                                      ? i.call(
   218                                          e,
   219                                          t,
   220                                          n.hijacked ||
   221                                          (n.hijacked = function (t) {
   222                                              t.propagationStopped || n(t);
   223                                          }),
   224                                          o
   225                                      )
   226                                      : i.call(e, t, n, o);
   227                              })),
   228                          "function" == typeof e.onclick &&
   229                          ((r = e.onclick),
   230                              e.addEventListener(
   231                                  "click",
   232                                  function (t) {
   233                                      r(t);
   234                                  },
   235                                  !1
   236                              ),
   237                              (e.onclick = null));
   238                  }
   239              }
   240              var e = navigator.userAgent.indexOf("Windows Phone") >= 0,
   241                  n = navigator.userAgent.indexOf("Android") > 0 && !e,
   242                  o = /iP(ad|hone|od)/.test(navigator.userAgent) && !e,
   243                  i = o && /OS 4_\d(_\d)?/.test(navigator.userAgent),
   244                  r = o && /OS [6-7]_\d/.test(navigator.userAgent),
   245                  s = navigator.userAgent.indexOf("BB10") > 0;
   246              (t.prototype.needsClick = function (t) {
   247                  switch (t.nodeName.toLowerCase()) {
   248                      case "button":
   249                      case "select":
   250                      case "textarea":
   251                          if (t.disabled) return !0;
   252                          break;
   253                      case "input":
   254                          if ((o && "file" === t.type) || t.disabled) return !0;
   255                          break;
   256                      case "label":
   257                      case "iframe":
   258                      case "video":
   259                          return !0;
   260                  }
   261                  return /\bneedsclick\b/.test(t.className);
   262              }),
   263                  (t.prototype.needsFocus = function (t) {
   264                      switch (t.nodeName.toLowerCase()) {
   265                          case "textarea":
   266                              return !0;
   267                          case "select":
   268                              return !n;
   269                          case "input":
   270                              switch (t.type) {
   271                                  case "button":
   272                                  case "checkbox":
   273                                  case "file":
   274                                  case "image":
   275                                  case "radio":
   276                                  case "submit":
   277                                      return !1;
   278                              }
   279                              return !t.disabled && !t.readOnly;
   280                          default:
   281                              return /\bneedsfocus\b/.test(t.className);
   282                      }
   283                  }),
   284                  (t.prototype.sendClick = function (t, e) {
   285                      var n, o;
   286                      document.activeElement &&
   287                          document.activeElement !== t &&
   288                          document.activeElement.blur(),
   289                          (o = e.changedTouches[0]),
   290                          (n = document.createEvent("MouseEvents")),
   291                          n.initMouseEvent(
   292                              this.determineEventType(t),
   293                              !0,
   294                              !0,
   295                              window,
   296                              1,
   297                              o.screenX,
   298                              o.screenY,
   299                              o.clientX,
   300                              o.clientY,
   301                              !1,
   302                              !1,
   303                              !1,
   304                              !1,
   305                              0,
   306                              null
   307                          ),
   308                          (n.forwardedTouchEvent = !0),
   309                          t.dispatchEvent(n);
   310                  }),
   311                  (t.prototype.determineEventType = function (t) {
   312                      return n && "select" === t.tagName.toLowerCase()
   313                          ? "mousedown"
   314                          : "click";
   315                  }),
   316                  (t.prototype.focus = function (t) {
   317                      var e;
   318                      o &&
   319                          t.setSelectionRange &&
   320                          0 !== t.type.indexOf("date") &&
   321                          "time" !== t.type &&
   322                          "month" !== t.type
   323                          ? ((e = t.value.length), t.setSelectionRange(e, e))
   324                          : t.focus();
   325                  }),
   326                  (t.prototype.updateScrollParent = function (t) {
   327                      var e, n;
   328                      if (((e = t.fastClickScrollParent), !e || !e.contains(t))) {
   329                          n = t;
   330                          do {
   331                              if (n.scrollHeight > n.offsetHeight) {
   332                                  (e = n), (t.fastClickScrollParent = n);
   333                                  break;
   334                              }
   335                              n = n.parentElement;
   336                          } while (n);
   337                      }
   338                      e && (e.fastClickLastScrollTop = e.scrollTop);
   339                  }),
   340                  (t.prototype.getTargetElementFromEventTarget = function (t) {
   341                      return t.nodeType === Node.TEXT_NODE ? t.parentNode : t;
   342                  }),
   343                  (t.prototype.onTouchStart = function (t) {
   344                      var e, n, r;
   345                      if (t.targetTouches.length > 1) return !0;
   346                      if (
   347                          ((e = this.getTargetElementFromEventTarget(t.target)),
   348                              (n = t.targetTouches[0]),
   349                              o)
   350                      ) {
   351                          if (((r = window.getSelection()), r.rangeCount && !r.isCollapsed))
   352                              return !0;
   353                          if (!i) {
   354                              if (n.identifier && n.identifier === this.lastTouchIdentifier)
   355                                  return t.preventDefault(), !1;
   356                              (this.lastTouchIdentifier = n.identifier),
   357                                  this.updateScrollParent(e);
   358                          }
   359                      }
   360                      return (
   361                          (this.trackingClick = !0),
   362                          (this.trackingClickStart = t.timeStamp),
   363                          (this.targetElement = e),
   364                          (this.touchStartX = n.pageX),
   365                          (this.touchStartY = n.pageY),
   366                          t.timeStamp - this.lastClickTime < this.tapDelay &&
   367                          t.preventDefault(),
   368                          !0
   369                      );
   370                  }),
   371                  (t.prototype.touchHasMoved = function (t) {
   372                      var e = t.changedTouches[0],
   373                          n = this.touchBoundary;
   374                      return Math.abs(e.pageX - this.touchStartX) > n ||
   375                          Math.abs(e.pageY - this.touchStartY) > n
   376                          ? !0
   377                          : !1;
   378                  }),
   379                  (t.prototype.onTouchMove = function (t) {
   380                      return this.trackingClick
   381                          ? ((this.targetElement !==
   382                              this.getTargetElementFromEventTarget(t.target) ||
   383                              this.touchHasMoved(t)) &&
   384                              ((this.trackingClick = !1), (this.targetElement = null)),
   385                              !0)
   386                          : !0;
   387                  }),
   388                  (t.prototype.findControl = function (t) {
   389                      return void 0 !== t.control
   390                          ? t.control
   391                          : t.htmlFor
   392                              ? document.getElementById(t.htmlFor)
   393                              : t.querySelector(
   394                                  "button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea"
   395                              );
   396                  }),
   397                  (t.prototype.onTouchEnd = function (t) {
   398                      var e,
   399                          s,
   400                          a,
   401                          c,
   402                          l,
   403                          u = this.targetElement;
   404                      if (!this.trackingClick) return !0;
   405                      if (t.timeStamp - this.lastClickTime < this.tapDelay)
   406                          return (this.cancelNextClick = !0), !0;
   407                      if (t.timeStamp - this.trackingClickStart > this.tapTimeout) return !0;
   408                      if (
   409                          ((this.cancelNextClick = !1),
   410                              (this.lastClickTime = t.timeStamp),
   411                              (s = this.trackingClickStart),
   412                              (this.trackingClick = !1),
   413                              (this.trackingClickStart = 0),
   414                              r &&
   415                              ((l = t.changedTouches[0]),
   416                                  (u =
   417                                      document.elementFromPoint(
   418                                          l.pageX - window.pageXOffset,
   419                                          l.pageY - window.pageYOffset
   420                                      ) || u),
   421                                  (u.fastClickScrollParent = this.targetElement.fastClickScrollParent)),
   422                              (a = u.tagName.toLowerCase()),
   423                              "label" === a)
   424                      ) {
   425                          if ((e = this.findControl(u))) {
   426                              if ((this.focus(u), n)) return !1;
   427                              u = e;
   428                          }
   429                      } else if (this.needsFocus(u))
   430                          return t.timeStamp - s > 100 ||
   431                              (o && window.top !== window && "input" === a)
   432                              ? ((this.targetElement = null), !1)
   433                              : (this.focus(u),
   434                                  this.sendClick(u, t),
   435                                  (o && "select" === a) ||
   436                                  ((this.targetElement = null), t.preventDefault()),
   437                                  !1);
   438                      return o &&
   439                          !i &&
   440                          ((c = u.fastClickScrollParent),
   441                              c && c.fastClickLastScrollTop !== c.scrollTop)
   442                          ? !0
   443                          : (this.needsClick(u) || (t.preventDefault(), this.sendClick(u, t)),
   444                              !1);
   445                  }),
   446                  (t.prototype.onTouchCancel = function () {
   447                      (this.trackingClick = !1), (this.targetElement = null);
   448                  }),
   449                  (t.prototype.onMouse = function (t) {
   450                      return this.targetElement
   451                          ? t.forwardedTouchEvent
   452                              ? !0
   453                              : t.cancelable &&
   454                                  (!this.needsClick(this.targetElement) || this.cancelNextClick)
   455                                  ? (t.stopImmediatePropagation
   456                                      ? t.stopImmediatePropagation()
   457                                      : (t.propagationStopped = !0),
   458                                      t.stopPropagation(),
   459                                      t.preventDefault(),
   460                                      !1)
   461                                  : !0
   462                          : !0;
   463                  }),
   464                  (t.prototype.onClick = function (t) {
   465                      var e;
   466                      return this.trackingClick
   467                          ? ((this.targetElement = null), (this.trackingClick = !1), !0)
   468                          : "submit" === t.target.type && 0 === t.detail
   469                              ? !0
   470                              : ((e = this.onMouse(t)), e || (this.targetElement = null), e);
   471                  }),
   472                  (t.prototype.destroy = function () {
   473                      var t = this.layer;
   474                      n &&
   475                          (t.removeEventListener("mouseover", this.onMouse, !0),
   476                              t.removeEventListener("mousedown", this.onMouse, !0),
   477                              t.removeEventListener("mouseup", this.onMouse, !0)),
   478                          t.removeEventListener("click", this.onClick, !0),
   479                          t.removeEventListener("touchstart", this.onTouchStart, !1),
   480                          t.removeEventListener("touchmove", this.onTouchMove, !1),
   481                          t.removeEventListener("touchend", this.onTouchEnd, !1),
   482                          t.removeEventListener("touchcancel", this.onTouchCancel, !1);
   483                  }),
   484                  (t.notNeeded = function (t) {
   485                      var e, o, i, r;
   486                      if ("undefined" == typeof window.ontouchstart) return !0;
   487                      if ((o = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1])) {
   488                          if (!n) return !0;
   489                          if ((e = document.querySelector("meta[name=viewport]"))) {
   490                              if (-1 !== e.content.indexOf("user-scalable=no")) return !0;
   491                              if (
   492                                  o > 31 &&
   493                                  document.documentElement.scrollWidth <= window.outerWidth
   494                              )
   495                                  return !0;
   496                          }
   497                      }
   498                      if (
   499                          s &&
   500                          ((i = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/)),
   501                              i[1] >= 10 &&
   502                              i[2] >= 3 &&
   503                              (e = document.querySelector("meta[name=viewport]")))
   504                      ) {
   505                          if (-1 !== e.content.indexOf("user-scalable=no")) return !0;
   506                          if (document.documentElement.scrollWidth <= window.outerWidth)
   507                              return !0;
   508                      }
   509                      return "none" === t.style.msTouchAction ||
   510                          "manipulation" === t.style.touchAction
   511                          ? !0
   512                          : ((r = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1]),
   513                              r >= 27 &&
   514                                  ((e = document.querySelector("meta[name=viewport]")),
   515                                      e &&
   516                                      (-1 !== e.content.indexOf("user-scalable=no") ||
   517                                          document.documentElement.scrollWidth <= window.outerWidth))
   518                                  ? !0
   519                                  : "none" === t.style.touchAction ||
   520                                      "manipulation" === t.style.touchAction
   521                                      ? !0
   522                                      : !1);
   523                  }),
   524                  (t.attach = function (e, n) {
   525                      return new t(e, n);
   526                  }),
   527                  "function" == typeof define && "object" == typeof define.amd && define.amd
   528                      ? define(function () {
   529                          return t;
   530                      })
   531                      : "undefined" != typeof module && module.exports
   532                          ? ((module.exports = t.attach), (module.exports.FastClick = t))
   533                          : (window.FastClick = t);
   534          })(),
   535          (function () {
   536              var t = function (e) {
   537                  var n = new t.Index();
   538                  return (
   539                      n.pipeline.add(t.trimmer, t.stopWordFilter, t.stemmer),
   540                      e && e.call(n, n),
   541                      n
   542                  );
   543              };
   544              (t.version = "0.6.0"),
   545                  (t.utils = {}),
   546                  (t.utils.warn = (function (t) {
   547                      return function (e) {
   548                          t.console && console.warn && console.warn(e);
   549                      };
   550                  })(this)),
   551                  (t.utils.asString = function (t) {
   552                      return void 0 === t || null === t ? "" : t.toString();
   553                  }),
   554                  (t.EventEmitter = function () {
   555                      this.events = {};
   556                  }),
   557                  (t.EventEmitter.prototype.addListener = function () {
   558                      var t = Array.prototype.slice.call(arguments),
   559                          e = t.pop(),
   560                          n = t;
   561                      if ("function" != typeof e)
   562                          throw new TypeError("last argument must be a function");
   563                      n.forEach(function (t) {
   564                          this.hasHandler(t) || (this.events[t] = []), this.events[t].push(e);
   565                      }, this);
   566                  }),
   567                  (t.EventEmitter.prototype.removeListener = function (t, e) {
   568                      if (this.hasHandler(t)) {
   569                          var n = this.events[t].indexOf(e);
   570                          this.events[t].splice(n, 1),
   571                              this.events[t].length || delete this.events[t];
   572                      }
   573                  }),
   574                  (t.EventEmitter.prototype.emit = function (t) {
   575                      if (this.hasHandler(t)) {
   576                          var e = Array.prototype.slice.call(arguments, 1);
   577                          this.events[t].forEach(function (t) {
   578                              t.apply(void 0, e);
   579                          });
   580                      }
   581                  }),
   582                  (t.EventEmitter.prototype.hasHandler = function (t) {
   583                      return t in this.events;
   584                  }),
   585                  (t.tokenizer = function (e) {
   586                      return arguments.length && null != e && void 0 != e
   587                          ? Array.isArray(e)
   588                              ? e.map(function (e) {
   589                                  return t.utils.asString(e).toLowerCase();
   590                              })
   591                              : e
   592                                  .toString()
   593                                  .trim()
   594                                  .toLowerCase()
   595                                  .split(t.tokenizer.seperator)
   596                          : [];
   597                  }),
   598                  (t.tokenizer.seperator = /[\s\-]+/),
   599                  (t.Pipeline = function () {
   600                      this._stack = [];
   601                  }),
   602                  (t.Pipeline.registeredFunctions = {}),
   603                  (t.Pipeline.registerFunction = function (e, n) {
   604                      n in this.registeredFunctions &&
   605                          t.utils.warn("Overwriting existing registered function: " + n),
   606                          (e.label = n),
   607                          (t.Pipeline.registeredFunctions[e.label] = e);
   608                  }),
   609                  (t.Pipeline.warnIfFunctionNotRegistered = function (e) {
   610                      var n = e.label && e.label in this.registeredFunctions;
   611                      n ||
   612                          t.utils.warn(
   613                              "Function is not registered with pipeline. This may cause problems when serialising the index.\n",
   614                              e
   615                          );
   616                  }),
   617                  (t.Pipeline.load = function (e) {
   618                      var n = new t.Pipeline();
   619                      return (
   620                          e.forEach(function (e) {
   621                              var o = t.Pipeline.registeredFunctions[e];
   622                              if (!o) throw new Error("Cannot load un-registered function: " + e);
   623                              n.add(o);
   624                          }),
   625                          n
   626                      );
   627                  }),
   628                  (t.Pipeline.prototype.add = function () {
   629                      var e = Array.prototype.slice.call(arguments);
   630                      e.forEach(function (e) {
   631                          t.Pipeline.warnIfFunctionNotRegistered(e), this._stack.push(e);
   632                      }, this);
   633                  }),
   634                  (t.Pipeline.prototype.after = function (e, n) {
   635                      t.Pipeline.warnIfFunctionNotRegistered(n);
   636                      var o = this._stack.indexOf(e);
   637                      if (-1 == o) throw new Error("Cannot find existingFn");
   638                      (o += 1), this._stack.splice(o, 0, n);
   639                  }),
   640                  (t.Pipeline.prototype.before = function (e, n) {
   641                      t.Pipeline.warnIfFunctionNotRegistered(n);
   642                      var o = this._stack.indexOf(e);
   643                      if (-1 == o) throw new Error("Cannot find existingFn");
   644                      this._stack.splice(o, 0, n);
   645                  }),
   646                  (t.Pipeline.prototype.remove = function (t) {
   647                      var e = this._stack.indexOf(t);
   648                      -1 != e && this._stack.splice(e, 1);
   649                  }),
   650                  (t.Pipeline.prototype.run = function (t) {
   651                      for (
   652                          var e = [], n = t.length, o = this._stack.length, i = 0;
   653                          n > i;
   654                          i++
   655                      ) {
   656                          for (
   657                              var r = t[i], s = 0;
   658                              o > s && ((r = this._stack[s](r, i, t)), void 0 !== r && "" !== r);
   659                              s++
   660                          );
   661                          void 0 !== r && "" !== r && e.push(r);
   662                      }
   663                      return e;
   664                  }),
   665                  (t.Pipeline.prototype.reset = function () {
   666                      this._stack = [];
   667                  }),
   668                  (t.Pipeline.prototype.toJSON = function () {
   669                      return this._stack.map(function (e) {
   670                          return t.Pipeline.warnIfFunctionNotRegistered(e), e.label;
   671                      });
   672                  }),
   673                  (t.Vector = function () {
   674                      (this._magnitude = null), (this.list = void 0), (this.length = 0);
   675                  }),
   676                  (t.Vector.Node = function (t, e, n) {
   677                      (this.idx = t), (this.val = e), (this.next = n);
   678                  }),
   679                  (t.Vector.prototype.insert = function (e, n) {
   680                      this._magnitude = void 0;
   681                      var o = this.list;
   682                      if (!o) return (this.list = new t.Vector.Node(e, n, o)), this.length++;
   683                      if (e < o.idx)
   684                          return (this.list = new t.Vector.Node(e, n, o)), this.length++;
   685                      for (var i = o, r = o.next; void 0 != r;) {
   686                          if (e < r.idx)
   687                              return (i.next = new t.Vector.Node(e, n, r)), this.length++;
   688                          (i = r), (r = r.next);
   689                      }
   690                      return (i.next = new t.Vector.Node(e, n, r)), this.length++;
   691                  }),
   692                  (t.Vector.prototype.magnitude = function () {
   693                      if (this._magnitude) return this._magnitude;
   694                      for (var t, e = this.list, n = 0; e;)
   695                          (t = e.val), (n += t * t), (e = e.next);
   696                      return (this._magnitude = Math.sqrt(n));
   697                  }),
   698                  (t.Vector.prototype.dot = function (t) {
   699                      for (var e = this.list, n = t.list, o = 0; e && n;)
   700                          e.idx < n.idx
   701                              ? (e = e.next)
   702                              : e.idx > n.idx
   703                                  ? (n = n.next)
   704                                  : ((o += e.val * n.val), (e = e.next), (n = n.next));
   705                      return o;
   706                  }),
   707                  (t.Vector.prototype.similarity = function (t) {
   708                      return this.dot(t) / (this.magnitude() * t.magnitude());
   709                  }),
   710                  (t.SortedSet = function () {
   711                      (this.length = 0), (this.elements = []);
   712                  }),
   713                  (t.SortedSet.load = function (t) {
   714                      var e = new this();
   715                      return (e.elements = t), (e.length = t.length), e;
   716                  }),
   717                  (t.SortedSet.prototype.add = function () {
   718                      var t, e;
   719                      for (t = 0; t < arguments.length; t++)
   720                          (e = arguments[t]),
   721                              ~this.indexOf(e) || this.elements.splice(this.locationFor(e), 0, e);
   722                      this.length = this.elements.length;
   723                  }),
   724                  (t.SortedSet.prototype.toArray = function () {
   725                      return this.elements.slice();
   726                  }),
   727                  (t.SortedSet.prototype.map = function (t, e) {
   728                      return this.elements.map(t, e);
   729                  }),
   730                  (t.SortedSet.prototype.forEach = function (t, e) {
   731                      return this.elements.forEach(t, e);
   732                  }),
   733                  (t.SortedSet.prototype.indexOf = function (t) {
   734                      for (
   735                          var e = 0,
   736                          n = this.elements.length,
   737                          o = n - e,
   738                          i = e + Math.floor(o / 2),
   739                          r = this.elements[i];
   740                          o > 1;
   741  
   742                      ) {
   743                          if (r === t) return i;
   744                          t > r && (e = i),
   745                              r > t && (n = i),
   746                              (o = n - e),
   747                              (i = e + Math.floor(o / 2)),
   748                              (r = this.elements[i]);
   749                      }
   750                      return r === t ? i : -1;
   751                  }),
   752                  (t.SortedSet.prototype.locationFor = function (t) {
   753                      for (
   754                          var e = 0,
   755                          n = this.elements.length,
   756                          o = n - e,
   757                          i = e + Math.floor(o / 2),
   758                          r = this.elements[i];
   759                          o > 1;
   760  
   761                      )
   762                          t > r && (e = i),
   763                              r > t && (n = i),
   764                              (o = n - e),
   765                              (i = e + Math.floor(o / 2)),
   766                              (r = this.elements[i]);
   767                      return r > t ? i : t > r ? i + 1 : void 0;
   768                  }),
   769                  (t.SortedSet.prototype.intersect = function (e) {
   770                      for (
   771                          var n = new t.SortedSet(),
   772                          o = 0,
   773                          i = 0,
   774                          r = this.length,
   775                          s = e.length,
   776                          a = this.elements,
   777                          c = e.elements;
   778                          ;
   779  
   780                      ) {
   781                          if (o > r - 1 || i > s - 1) break;
   782                          a[o] !== c[i]
   783                              ? a[o] < c[i]
   784                                  ? o++
   785                                  : a[o] > c[i] && i++
   786                              : (n.add(a[o]), o++ , i++);
   787                      }
   788                      return n;
   789                  }),
   790                  (t.SortedSet.prototype.clone = function () {
   791                      var e = new t.SortedSet();
   792                      return (e.elements = this.toArray()), (e.length = e.elements.length), e;
   793                  }),
   794                  (t.SortedSet.prototype.union = function (t) {
   795                      var e, n, o;
   796                      return (
   797                          this.length >= t.length
   798                              ? ((e = this), (n = t))
   799                              : ((e = t), (n = this)),
   800                          (o = e.clone()),
   801                          o.add.apply(o, n.toArray()),
   802                          o
   803                      );
   804                  }),
   805                  (t.SortedSet.prototype.toJSON = function () {
   806                      return this.toArray();
   807                  }),
   808                  (t.Index = function () {
   809                      (this._fields = []),
   810                          (this._ref = "id"),
   811                          (this.pipeline = new t.Pipeline()),
   812                          (this.documentStore = new t.Store()),
   813                          (this.tokenStore = new t.TokenStore()),
   814                          (this.corpusTokens = new t.SortedSet()),
   815                          (this.eventEmitter = new t.EventEmitter()),
   816                          (this._idfCache = {}),
   817                          this.on(
   818                              "add",
   819                              "remove",
   820                              "update",
   821                              function () {
   822                                  this._idfCache = {};
   823                              }.bind(this)
   824                          );
   825                  }),
   826                  (t.Index.prototype.on = function () {
   827                      var t = Array.prototype.slice.call(arguments);
   828                      return this.eventEmitter.addListener.apply(this.eventEmitter, t);
   829                  }),
   830                  (t.Index.prototype.off = function (t, e) {
   831                      return this.eventEmitter.removeListener(t, e);
   832                  }),
   833                  (t.Index.load = function (e) {
   834                      e.version !== t.version &&
   835                          t.utils.warn(
   836                              "version mismatch: current " + t.version + " importing " + e.version
   837                          );
   838                      var n = new this();
   839                      return (
   840                          (n._fields = e.fields),
   841                          (n._ref = e.ref),
   842                          (n.documentStore = t.Store.load(e.documentStore)),
   843                          (n.tokenStore = t.TokenStore.load(e.tokenStore)),
   844                          (n.corpusTokens = t.SortedSet.load(e.corpusTokens)),
   845                          (n.pipeline = t.Pipeline.load(e.pipeline)),
   846                          n
   847                      );
   848                  }),
   849                  (t.Index.prototype.field = function (t, e) {
   850                      var e = e || {},
   851                          n = { name: t, boost: e.boost || 1 };
   852                      return this._fields.push(n), this;
   853                  }),
   854                  (t.Index.prototype.ref = function (t) {
   855                      return (this._ref = t), this;
   856                  }),
   857                  (t.Index.prototype.add = function (e, n) {
   858                      var o = {},
   859                          i = new t.SortedSet(),
   860                          r = e[this._ref],
   861                          n = void 0 === n ? !0 : n;
   862                      this._fields.forEach(function (n) {
   863                          var r = this.pipeline.run(t.tokenizer(e[n.name]));
   864                          (o[n.name] = r), t.SortedSet.prototype.add.apply(i, r);
   865                      }, this),
   866                          this.documentStore.set(r, i),
   867                          t.SortedSet.prototype.add.apply(this.corpusTokens, i.toArray());
   868                      for (var s = 0; s < i.length; s++) {
   869                          var a = i.elements[s],
   870                              c = this._fields.reduce(function (t, e) {
   871                                  var n = o[e.name].length;
   872                                  if (!n) return t;
   873                                  var i = o[e.name].filter(function (t) {
   874                                      return t === a;
   875                                  }).length;
   876                                  return t + (i / n) * e.boost;
   877                              }, 0);
   878                          this.tokenStore.add(a, { ref: r, tf: c });
   879                      }
   880                      n && this.eventEmitter.emit("add", e, this);
   881                  }),
   882                  (t.Index.prototype.remove = function (t, e) {
   883                      var n = t[this._ref],
   884                          e = void 0 === e ? !0 : e;
   885                      if (this.documentStore.has(n)) {
   886                          var o = this.documentStore.get(n);
   887                          this.documentStore.remove(n),
   888                              o.forEach(function (t) {
   889                                  this.tokenStore.remove(t, n);
   890                              }, this),
   891                              e && this.eventEmitter.emit("remove", t, this);
   892                      }
   893                  }),
   894                  (t.Index.prototype.update = function (t, e) {
   895                      var e = void 0 === e ? !0 : e;
   896                      this.remove(t, !1),
   897                          this.add(t, !1),
   898                          e && this.eventEmitter.emit("update", t, this);
   899                  }),
   900                  (t.Index.prototype.idf = function (t) {
   901                      var e = "@" + t;
   902                      if (Object.prototype.hasOwnProperty.call(this._idfCache, e))
   903                          return this._idfCache[e];
   904                      var n = this.tokenStore.count(t),
   905                          o = 1;
   906                      return (
   907                          n > 0 && (o = 1 + Math.log(this.documentStore.length / n)),
   908                          (this._idfCache[e] = o)
   909                      );
   910                  }),
   911                  (t.Index.prototype.search = function (e) {
   912                      var n = this.pipeline.run(t.tokenizer(e)),
   913                          o = new t.Vector(),
   914                          i = [],
   915                          r = this._fields.reduce(function (t, e) {
   916                              return t + e.boost;
   917                          }, 0),
   918                          s = n.some(function (t) {
   919                              return this.tokenStore.has(t);
   920                          }, this);
   921                      if (!s) return [];
   922                      n.forEach(function (e, n, s) {
   923                          var a = (1 / s.length) * this._fields.length * r,
   924                              c = this,
   925                              l = this.tokenStore.expand(e).reduce(function (n, i) {
   926                                  var r = c.corpusTokens.indexOf(i),
   927                                      s = c.idf(i),
   928                                      l = 1,
   929                                      u = new t.SortedSet();
   930                                  if (i !== e) {
   931                                      var d = Math.max(3, i.length - e.length);
   932                                      l = 1 / Math.log(d);
   933                                  }
   934                                  r > -1 && o.insert(r, a * s * l);
   935                                  for (
   936                                      var h = c.tokenStore.get(i),
   937                                      f = Object.keys(h),
   938                                      p = f.length,
   939                                      m = 0;
   940                                      p > m;
   941                                      m++
   942                                  )
   943                                      u.add(h[f[m]].ref);
   944                                  return n.union(u);
   945                              }, new t.SortedSet());
   946                          i.push(l);
   947                      }, this);
   948                      var a = i.reduce(function (t, e) {
   949                          return t.intersect(e);
   950                      });
   951                      return a
   952                          .map(function (t) {
   953                              return { ref: t, score: o.similarity(this.documentVector(t)) };
   954                          }, this)
   955                          .sort(function (t, e) {
   956                              return e.score - t.score;
   957                          });
   958                  }),
   959                  (t.Index.prototype.documentVector = function (e) {
   960                      for (
   961                          var n = this.documentStore.get(e),
   962                          o = n.length,
   963                          i = new t.Vector(),
   964                          r = 0;
   965                          o > r;
   966                          r++
   967                      ) {
   968                          var s = n.elements[r],
   969                              a = this.tokenStore.get(s)[e].tf,
   970                              c = this.idf(s);
   971                          i.insert(this.corpusTokens.indexOf(s), a * c);
   972                      }
   973                      return i;
   974                  }),
   975                  (t.Index.prototype.toJSON = function () {
   976                      return {
   977                          version: t.version,
   978                          fields: this._fields,
   979                          ref: this._ref,
   980                          documentStore: this.documentStore.toJSON(),
   981                          tokenStore: this.tokenStore.toJSON(),
   982                          corpusTokens: this.corpusTokens.toJSON(),
   983                          pipeline: this.pipeline.toJSON()
   984                      };
   985                  }),
   986                  (t.Index.prototype.use = function (t) {
   987                      var e = Array.prototype.slice.call(arguments, 1);
   988                      e.unshift(this), t.apply(this, e);
   989                  }),
   990                  (t.Store = function () {
   991                      (this.store = {}), (this.length = 0);
   992                  }),
   993                  (t.Store.load = function (e) {
   994                      var n = new this();
   995                      return (
   996                          (n.length = e.length),
   997                          (n.store = Object.keys(e.store).reduce(function (n, o) {
   998                              return (n[o] = t.SortedSet.load(e.store[o])), n;
   999                          }, {})),
  1000                          n
  1001                      );
  1002                  }),
  1003                  (t.Store.prototype.set = function (t, e) {
  1004                      this.has(t) || this.length++ , (this.store[t] = e);
  1005                  }),
  1006                  (t.Store.prototype.get = function (t) {
  1007                      return this.store[t];
  1008                  }),
  1009                  (t.Store.prototype.has = function (t) {
  1010                      return t in this.store;
  1011                  }),
  1012                  (t.Store.prototype.remove = function (t) {
  1013                      this.has(t) && (delete this.store[t], this.length--);
  1014                  }),
  1015                  (t.Store.prototype.toJSON = function () {
  1016                      return { store: this.store, length: this.length };
  1017                  }),
  1018                  (t.stemmer = (function () {
  1019                      var t = {
  1020                          ational: "ate",
  1021                          tional: "tion",
  1022                          enci: "ence",
  1023                          anci: "ance",
  1024                          izer: "ize",
  1025                          bli: "ble",
  1026                          alli: "al",
  1027                          entli: "ent",
  1028                          eli: "e",
  1029                          ousli: "ous",
  1030                          ization: "ize",
  1031                          ation: "ate",
  1032                          ator: "ate",
  1033                          alism: "al",
  1034                          iveness: "ive",
  1035                          fulness: "ful",
  1036                          ousness: "ous",
  1037                          aliti: "al",
  1038                          iviti: "ive",
  1039                          biliti: "ble",
  1040                          logi: "log"
  1041                      },
  1042                          e = {
  1043                              icate: "ic",
  1044                              ative: "",
  1045                              alize: "al",
  1046                              iciti: "ic",
  1047                              ical: "ic",
  1048                              ful: "",
  1049                              ness: ""
  1050                          },
  1051                          n = "[^aeiou]",
  1052                          o = "[aeiouy]",
  1053                          i = n + "[^aeiouy]*",
  1054                          r = o + "[aeiou]*",
  1055                          s = "^(" + i + ")?" + r + i,
  1056                          a = "^(" + i + ")?" + r + i + "(" + r + ")?$",
  1057                          c = "^(" + i + ")?" + r + i + r + i,
  1058                          l = "^(" + i + ")?" + o,
  1059                          u = new RegExp(s),
  1060                          d = new RegExp(c),
  1061                          h = new RegExp(a),
  1062                          f = new RegExp(l),
  1063                          p = /^(.+?)(ss|i)es$/,
  1064                          m = /^(.+?)([^s])s$/,
  1065                          v = /^(.+?)eed$/,
  1066                          g = /^(.+?)(ed|ing)$/,
  1067                          y = /.$/,
  1068                          w = /(at|bl|iz)$/,
  1069                          S = new RegExp("([^aeiouylsz])\\1$"),
  1070                          k = new RegExp("^" + i + o + "[^aeiouwxy]$"),
  1071                          E = /^(.+?[^aeiou])y$/,
  1072                          x = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,
  1073                          b = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,
  1074                          T = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,
  1075                          C = /^(.+?)(s|t)(ion)$/,
  1076                          L = /^(.+?)e$/,
  1077                          _ = /ll$/,
  1078                          A = new RegExp("^" + i + o + "[^aeiouwxy]$"),
  1079                          O = function (n) {
  1080                              var o, i, r, s, a, c, l;
  1081                              if (n.length < 3) return n;
  1082                              if (
  1083                                  ((r = n.substr(0, 1)),
  1084                                      "y" == r && (n = r.toUpperCase() + n.substr(1)),
  1085                                      (s = p),
  1086                                      (a = m),
  1087                                      s.test(n)
  1088                                          ? (n = n.replace(s, "$1$2"))
  1089                                          : a.test(n) && (n = n.replace(a, "$1$2")),
  1090                                      (s = v),
  1091                                      (a = g),
  1092                                      s.test(n))
  1093                              ) {
  1094                                  var O = s.exec(n);
  1095                                  (s = u), s.test(O[1]) && ((s = y), (n = n.replace(s, "")));
  1096                              } else if (a.test(n)) {
  1097                                  var O = a.exec(n);
  1098                                  (o = O[1]),
  1099                                      (a = f),
  1100                                      a.test(o) &&
  1101                                      ((n = o),
  1102                                          (a = w),
  1103                                          (c = S),
  1104                                          (l = k),
  1105                                          a.test(n)
  1106                                              ? (n += "e")
  1107                                              : c.test(n)
  1108                                                  ? ((s = y), (n = n.replace(s, "")))
  1109                                                  : l.test(n) && (n += "e"));
  1110                              }
  1111                              if (((s = E), s.test(n))) {
  1112                                  var O = s.exec(n);
  1113                                  (o = O[1]), (n = o + "i");
  1114                              }
  1115                              if (((s = x), s.test(n))) {
  1116                                  var O = s.exec(n);
  1117                                  (o = O[1]), (i = O[2]), (s = u), s.test(o) && (n = o + t[i]);
  1118                              }
  1119                              if (((s = b), s.test(n))) {
  1120                                  var O = s.exec(n);
  1121                                  (o = O[1]), (i = O[2]), (s = u), s.test(o) && (n = o + e[i]);
  1122                              }
  1123                              if (((s = T), (a = C), s.test(n))) {
  1124                                  var O = s.exec(n);
  1125                                  (o = O[1]), (s = d), s.test(o) && (n = o);
  1126                              } else if (a.test(n)) {
  1127                                  var O = a.exec(n);
  1128                                  (o = O[1] + O[2]), (a = d), a.test(o) && (n = o);
  1129                              }
  1130                              if (((s = L), s.test(n))) {
  1131                                  var O = s.exec(n);
  1132                                  (o = O[1]),
  1133                                      (s = d),
  1134                                      (a = h),
  1135                                      (c = A),
  1136                                      (s.test(o) || (a.test(o) && !c.test(o))) && (n = o);
  1137                              }
  1138                              return (
  1139                                  (s = _),
  1140                                  (a = d),
  1141                                  s.test(n) && a.test(n) && ((s = y), (n = n.replace(s, ""))),
  1142                                  "y" == r && (n = r.toLowerCase() + n.substr(1)),
  1143                                  n
  1144                              );
  1145                          };
  1146                      return O;
  1147                  })()),
  1148                  t.Pipeline.registerFunction(t.stemmer, "stemmer"),
  1149                  (t.generateStopWordFilter = function (t) {
  1150                      var e = t.reduce(function (t, e) {
  1151                          return (t[e] = e), t;
  1152                      }, {});
  1153                      return function (t) {
  1154                          return t && e[t] !== t ? t : void 0;
  1155                      };
  1156                  }),
  1157                  (t.stopWordFilter = t.generateStopWordFilter([
  1158                      "a",
  1159                      "able",
  1160                      "about",
  1161                      "across",
  1162                      "after",
  1163                      "all",
  1164                      "almost",
  1165                      "also",
  1166                      "am",
  1167                      "among",
  1168                      "an",
  1169                      "and",
  1170                      "any",
  1171                      "are",
  1172                      "as",
  1173                      "at",
  1174                      "be",
  1175                      "because",
  1176                      "been",
  1177                      "but",
  1178                      "by",
  1179                      "can",
  1180                      "cannot",
  1181                      "could",
  1182                      "dear",
  1183                      "did",
  1184                      "do",
  1185                      "does",
  1186                      "either",
  1187                      "else",
  1188                      "ever",
  1189                      "every",
  1190                      "for",
  1191                      "from",
  1192                      "get",
  1193                      "got",
  1194                      "had",
  1195                      "has",
  1196                      "have",
  1197                      "he",
  1198                      "her",
  1199                      "hers",
  1200                      "him",
  1201                      "his",
  1202                      "how",
  1203                      "however",
  1204                      "i",
  1205                      "if",
  1206                      "in",
  1207                      "into",
  1208                      "is",
  1209                      "it",
  1210                      "its",
  1211                      "just",
  1212                      "least",
  1213                      "let",
  1214                      "like",
  1215                      "likely",
  1216                      "may",
  1217                      "me",
  1218                      "might",
  1219                      "most",
  1220                      "must",
  1221                      "my",
  1222                      "neither",
  1223                      "no",
  1224                      "nor",
  1225                      "not",
  1226                      "of",
  1227                      "off",
  1228                      "often",
  1229                      "on",
  1230                      "only",
  1231                      "or",
  1232                      "other",
  1233                      "our",
  1234                      "own",
  1235                      "rather",
  1236                      "said",
  1237                      "say",
  1238                      "says",
  1239                      "she",
  1240                      "should",
  1241                      "since",
  1242                      "so",
  1243                      "some",
  1244                      "than",
  1245                      "that",
  1246                      "the",
  1247                      "their",
  1248                      "them",
  1249                      "then",
  1250                      "there",
  1251                      "these",
  1252                      "they",
  1253                      "this",
  1254                      "tis",
  1255                      "to",
  1256                      "too",
  1257                      "twas",
  1258                      "us",
  1259                      "wants",
  1260                      "was",
  1261                      "we",
  1262                      "were",
  1263                      "what",
  1264                      "when",
  1265                      "where",
  1266                      "which",
  1267                      "while",
  1268                      "who",
  1269                      "whom",
  1270                      "why",
  1271                      "will",
  1272                      "with",
  1273                      "would",
  1274                      "yet",
  1275                      "you",
  1276                      "your"
  1277                  ])),
  1278                  t.Pipeline.registerFunction(t.stopWordFilter, "stopWordFilter"),
  1279                  (t.trimmer = function (t) {
  1280                      return t.replace(/^\W+/, "").replace(/\W+$/, "");
  1281                  }),
  1282                  t.Pipeline.registerFunction(t.trimmer, "trimmer"),
  1283                  (t.TokenStore = function () {
  1284                      (this.root = { docs: {} }), (this.length = 0);
  1285                  }),
  1286                  (t.TokenStore.load = function (t) {
  1287                      var e = new this();
  1288                      return (e.root = t.root), (e.length = t.length), e;
  1289                  }),
  1290                  (t.TokenStore.prototype.add = function (t, e, n) {
  1291                      var n = n || this.root,
  1292                          o = t.charAt(0),
  1293                          i = t.slice(1);
  1294                      return (
  1295                          o in n || (n[o] = { docs: {} }),
  1296                          0 === i.length
  1297                              ? ((n[o].docs[e.ref] = e), void (this.length += 1))
  1298                              : this.add(i, e, n[o])
  1299                      );
  1300                  }),
  1301                  (t.TokenStore.prototype.has = function (t) {
  1302                      if (!t) return !1;
  1303                      for (var e = this.root, n = 0; n < t.length; n++) {
  1304                          if (!e[t.charAt(n)]) return !1;
  1305                          e = e[t.charAt(n)];
  1306                      }
  1307                      return !0;
  1308                  }),
  1309                  (t.TokenStore.prototype.getNode = function (t) {
  1310                      if (!t) return {};
  1311                      for (var e = this.root, n = 0; n < t.length; n++) {
  1312                          if (!e[t.charAt(n)]) return {};
  1313                          e = e[t.charAt(n)];
  1314                      }
  1315                      return e;
  1316                  }),
  1317                  (t.TokenStore.prototype.get = function (t, e) {
  1318                      return this.getNode(t, e).docs || {};
  1319                  }),
  1320                  (t.TokenStore.prototype.count = function (t, e) {
  1321                      return Object.keys(this.get(t, e)).length;
  1322                  }),
  1323                  (t.TokenStore.prototype.remove = function (t, e) {
  1324                      if (t) {
  1325                          for (var n = this.root, o = 0; o < t.length; o++) {
  1326                              if (!(t.charAt(o) in n)) return;
  1327                              n = n[t.charAt(o)];
  1328                          }
  1329                          delete n.docs[e];
  1330                      }
  1331                  }),
  1332                  (t.TokenStore.prototype.expand = function (t, e) {
  1333                      var n = this.getNode(t),
  1334                          o = n.docs || {},
  1335                          e = e || [];
  1336                      return (
  1337                          Object.keys(o).length && e.push(t),
  1338                          Object.keys(n).forEach(function (n) {
  1339                              "docs" !== n && e.concat(this.expand(t + n, e));
  1340                          }, this),
  1341                          e
  1342                      );
  1343                  }),
  1344                  (t.TokenStore.prototype.toJSON = function () {
  1345                      return { root: this.root, length: this.length };
  1346                  }),
  1347                  (function (t, e) {
  1348                      "function" == typeof define && define.amd
  1349                          ? define(e)
  1350                          : "object" == typeof exports
  1351                              ? (module.exports = e())
  1352                              : (t.lunr = e());
  1353                  })(this, function () {
  1354                      return t;
  1355                  });
  1356          })(),
  1357          (String.prototype.truncate = function (t) {
  1358              if (this.length > t) {
  1359                  for (; " " != this[t] && --t > 0;);
  1360                  return this.substring(0, t) + "&hellip;";
  1361              }
  1362              return this;
  1363          }),
  1364          (HTMLElement.prototype.wrap = function (t) {
  1365              t.length || (t = [t]);
  1366              for (var e = t.length - 1; e >= 0; e--) {
  1367                  var n = e > 0 ? this.cloneNode(!0) : this,
  1368                      o = t[e],
  1369                      i = o.parentNode,
  1370                      r = o.nextSibling;
  1371                  n.appendChild(o), r ? i.insertBefore(n, r) : i.appendChild(n);
  1372              }
  1373          }),
  1374          document.addEventListener("DOMContentLoaded", function () {
  1375              "use strict";
  1376              Modernizr.addTest("ios", function () {
  1377                  return !!navigator.userAgent.match(/(iPad|iPhone|iPod)/g);
  1378              }),
  1379                  Modernizr.addTest("standalone", function () {
  1380                      return !!navigator.standalone;
  1381                  }),
  1382                  FastClick.attach(document.body);
  1383              var t = document.getElementById("toggle-search"),
  1384                  e = (document.getElementById("reset-search"),
  1385                      document.querySelector(".drawer")),
  1386                  n = document.querySelectorAll(".anchor"),
  1387                  o = document.querySelector(".search .field"),
  1388                  i = document.querySelector(".query"),
  1389                  r = document.querySelector(".results .meta");
  1390              Array.prototype.forEach.call(n, function (t) {
  1391                  t.querySelector("a").addEventListener("click", function () {
  1392                      (document.getElementById("toggle-drawer").checked = !1),
  1393                          document.body.classList.remove("toggle-drawer");
  1394                  });
  1395              });
  1396              var s = window.pageYOffset,
  1397                  a = function () {
  1398                      var t = window.pageYOffset + window.innerHeight,
  1399                          n = Math.max(0, window.innerHeight - e.offsetHeight);
  1400                      t > document.body.clientHeight - (96 - n)
  1401                          ? "absolute" != e.style.position &&
  1402                          ((e.style.position = "absolute"),
  1403                              (e.style.top = null),
  1404                              (e.style.bottom = 0))
  1405                          : e.offsetHeight < window.innerHeight
  1406                              ? "fixed" != e.style.position &&
  1407                              ((e.style.position = "fixed"),
  1408                                  (e.style.top = 0),
  1409                                  (e.style.bottom = null))
  1410                              : "fixed" != e.style.position
  1411                                  ? t > e.offsetTop + e.offsetHeight
  1412                                      ? ((e.style.position = "fixed"),
  1413                                          (e.style.top = null),
  1414                                          (e.style.bottom = "-96px"))
  1415                                      : window.pageYOffset < e.offsetTop &&
  1416                                      ((e.style.position = "fixed"),
  1417                                          (e.style.top = 0),
  1418                                          (e.style.bottom = null))
  1419                                  : window.pageYOffset > s
  1420                                      ? e.style.top &&
  1421                                      ((e.style.position = "absolute"),
  1422                                          (e.style.top = Math.max(0, s) + "px"),
  1423                                          (e.style.bottom = null))
  1424                                      : e.style.bottom &&
  1425                                      ((e.style.position = "absolute"),
  1426                                          (e.style.top = t - e.offsetHeight + "px"),
  1427                                          (e.style.bottom = null)),
  1428                          (s = Math.max(0, window.pageYOffset));
  1429                  },
  1430                  c = function () {
  1431                      var t = document.querySelector(".main");
  1432                      window.removeEventListener("scroll", a),
  1433                          matchMedia("only screen and (max-width: 959px)").matches
  1434                              ? ((e.style.position = null),
  1435                                  (e.style.top = null),
  1436                                  (e.style.bottom = null))
  1437                              : e.offsetHeight + 96 < t.offsetHeight &&
  1438                              (window.addEventListener("scroll", a), a());
  1439                  };
  1440              Modernizr.ios || (window.addEventListener("resize", c), c());
  1441              var u = 0;
  1442              t.addEventListener("click", function (t) {
  1443                  var e = document.body.classList,
  1444                      n = !matchMedia("only screen and (min-width: 960px)").matches;
  1445                  e.contains("locked")
  1446                      ? (e.remove("locked"),
  1447                          n &&
  1448                          setTimeout(function () {
  1449                              window.scrollTo(0, u);
  1450                          }, 100))
  1451                      : ((u = window.scrollY),
  1452                          n &&
  1453                          setTimeout(function () {
  1454                              window.scrollTo(0, 0);
  1455                          }, 400),
  1456                          setTimeout(
  1457                              function () {
  1458                                  this.checked &&
  1459                                      (n && e.add("locked"),
  1460                                          setTimeout(function () {
  1461                                              i.focus();
  1462                                          }, 200));
  1463                              }.bind(this),
  1464                              450
  1465                          ));
  1466              }),
  1467                  o.addEventListener("touchstart", function () {
  1468                      i.focus();
  1469                  }),
  1470                  window.addEventListener("keyup", function (e) {
  1471                      var n = e.keyCode || e.which;
  1472                      27 == n &&
  1473                          (i.blur(),
  1474                              document.body.classList.remove("toggle-search"),
  1475                              document.body.classList.remove("locked"),
  1476                              (t.checked = !1));
  1477                  });
  1478              var d = document.getElementById("reset-search");
  1479              d.addEventListener("click", function () {
  1480                  for (var t = document.querySelector(".results .list"); t.firstChild;)
  1481                      t.removeChild(t.firstChild);
  1482                  var e = document.querySelector(".bar.search");
  1483                  e.classList.remove("non-empty"),
  1484                      (r.innerHTML = ""),
  1485                      (i.value = ""),
  1486                      i.focus();
  1487              });
  1488              var h = document.querySelectorAll("h2");
  1489              h = Array.prototype.map.call(h, function (t) {
  1490                  return t.offsetTop;
  1491              });
  1492              var f = null;
  1493              document.addEventListener("scroll", function () {
  1494                  for (
  1495                      var t = window.scrollY + window.innerHeight / 3,
  1496                      e = h.length - 1,
  1497                      o = 0;
  1498                      e > o;
  1499                      o++
  1500                  )
  1501                      t < h[o + 1] && (e = o);
  1502                  e != f &&
  1503                      ((f = e),
  1504                          Array.prototype.forEach.call(n, function (t, e) {
  1505                              var n = t.querySelector("a");
  1506                              (e != f || n.classList.add("current")) &&
  1507                                  n.classList.remove("current");
  1508                          }));
  1509              });
  1510              var p = document.querySelectorAll(".n + .p");
  1511              Array.prototype.forEach.call(p, function (t) {
  1512                  var e = t.innerText || t.textContent;
  1513                  e && "(" == e[0] && t.previousSibling.classList.add("f");
  1514              });
  1515              var m = document.querySelectorAll("table");
  1516              if (
  1517                  (Array.prototype.forEach.call(m, function (t) {
  1518                      var e = document.createElement("div");
  1519                      e.classList.add("data"), e.wrap(t);
  1520                  }),
  1521                      Modernizr.ios)
  1522              ) {
  1523                  var v = document.querySelectorAll(".scrollable, .standalone .article");
  1524                  Array.prototype.forEach.call(v, function (t) {
  1525                      t.addEventListener("touchstart", function () {
  1526                          var t = this.scrollTop;
  1527                          0 == t
  1528                              ? (this.scrollTop = 1)
  1529                              : t + this.offsetHeight == this.scrollHeight &&
  1530                              (this.scrollTop = t - 1);
  1531                      });
  1532                  });
  1533              }
  1534              var g = document.querySelectorAll(".project, .overlay, .header");
  1535              Array.prototype.forEach.call(g, function (t) {
  1536                  t.addEventListener("touchmove", function (t) {
  1537                      t.preventDefault();
  1538                  });
  1539              });
  1540              var y = document.querySelectorAll(".toggle");
  1541              Array.prototype.forEach.call(y, function (t) {
  1542                  t.addEventListener("click", function () {
  1543                      document.body.classList.toggle(this.id);
  1544                  });
  1545              }),
  1546                  repo_id &&
  1547                  pegasus("https://api.github.com/repos/" + repo_id).then(
  1548                      function (t, e) {
  1549                          var n = t.stargazers_count;
  1550                          n > 1e4
  1551                              ? (n = (n / 1e3).toFixed(0) + "k")
  1552                              : n > 1e3 && (n = (n / 1e3).toFixed(1) + "k");
  1553                          var o = document.querySelector(".repo-stars .count");
  1554                          o.innerHTML = n;
  1555                      },
  1556                      function (t, e) {
  1557                          console.error(t, e.status);
  1558                      }
  1559                  );
  1560          }),
  1561          "standalone" in window.navigator && window.navigator.standalone)
  1562  ) {
  1563      var node,
  1564          remotes = !1;
  1565      document.addEventListener(
  1566          "click",
  1567          function (t) {
  1568              for (node = t.target; "A" !== node.nodeName && "HTML" !== node.nodeName;)
  1569                  node = node.parentNode;
  1570              "href" in node &&
  1571                  -1 !== node.href.indexOf("http") &&
  1572                  (-1 !== node.href.indexOf(document.location.host) || remotes) &&
  1573                  (t.preventDefault(), (document.location.href = node.href));
  1574          },
  1575          !1
  1576      );
  1577  }