(function () {
  var c,
  s,
  f,
  u,
  i,
  r,
  x,
  m,
  p,
  g,
  o,
  _,
  l,
  d,
  h,
  t,
  w,
  v,
  y,
  e,
  k,
  a,
  n,
  b,
  S,
  A,
  M,
  E,
  R,
  C,
  q,
  O,
  T,
  j,
  I,
  P,
  L,
  N,
  D,
  H;
  r = {
    'str-contents': 'Contents',
    'str-terms': 'Index',
    'str-search': 'Search',
    'str-topic': 'Topic',
    'str-searching': 'Searching...',
    'str-loading': 'loading',
    'str-previous': 'Previous',
    'str-next': 'Next',
    'str-home': 'Home',
    'str-search-empty': 'not found',
    'str-search-error': 'search failed',
    'str-search-common-words': ''
  },
  S = function (e) {
    try {
      return window.getComputedStyle(document.querySelector('.' + e), ':before').getPropertyValue('content').replace(/\"/g, '')
    } catch (t) {
      return t,
      r[e]
    }
  },
  n = function (t, e) {
    var r;
    return (r = new RegExp('[?&]' + t + '=([^&#]*)').exec(window.location.href)) && r[1] || e || ''
  },
  H = function () {
    var t,
    e;
    t = Array.prototype.slice.call(arguments),
    void 0 !== (e = parent.frames[t.shift()]) && e && e.postMessage(t.join('[||]'), '*')
  },
  N = function () {
    window.parent.postMessage(Array.prototype.slice.call(arguments).join('[||]'), '*')
  },
  t = function (r) {
    window.addEventListener('message', function (t) {
      var e;
      e = (t.data || t).split('[||]'),
      r(e.shift(), e || null)
    })
  },
  M = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream,
  e = document.documentElement,
  !M && parent !== self && window.addEventListener('scroll', function () {
    var t;
    t = (window.pageYOffset || e.scrollTop) - (e.clientTop || 0),
    parent.window.postMessage(['scroll',
    window.name,
    t.toString()].join('[||]'), '*'),
    t
  }),
  m = {
    string: '',
    terms: [
    ],
    exclusions: !1,
    ored: !1,
    exact_matches: !1
  },
  p = [
  ],
  c = S('str-search-common-words'),
  x = 150,
  l = '(?:' + (_ = /[\s()|.,:;{}[\]'"+!?\-«»“”„`’‹›—–−]/).source + '|^)',
  o = '(?:' + _.source + '|$)',
  E = null,
  h = !(d = 'ZQXQZ'),
  A = function (t) {
    return t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
  },
  k = function (t, e) {
    var r,
    n,
    a,
    i;
    return i = x < e ? e - 75 : 0,
    r = t.substr(i, x),
    a = 0 === i ? 0 : r.indexOf(' '),
    n = (n = r.lastIndexOf(' ')) <= (a = - 1 === a ? 0 : a) ? r.length : n,
    r = r.substring(a, n).replace(/[., ]+$/, ''),
    0 < e && (r = '...' + r),
    n < t.length && (r += '...'),
    r
  },
  j = function (t) {
    var e,
    r,
    n,
    a,
    i,
    s;
    if (0 === c.length) return t;
    for (r = '', n = 0, a = (e = c.split(' ')).length; n < a; n++) s = e[n],
    i = new RegExp('\\b' + s + '\\b', 'gi'),
    - 1 !== t.search(i) && (r += '<b>' + s + '</b>, ', t = t.replace(i, ''));
    return 0 < r.length && (t = t.replace(/\s+/g, ' ')),
    t
  },
  R = function (t, e) {
    return t = String(t).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1').replace(/\x08/g, '\\x08'),
    e && (t = t.replace(/\\\?/g, '\\S').replace(/\\\*/g, '\\S*')),
    t
  },
  b = function (t, e) {
    var r,
    n,
    a,
    i,
    s,
    c;
    return a = n = s = !1,
    '+' === t.charAt(0) ? t = t.substring(1)  : '-' === t.charAt(0) ? (t = t.substring(1), a = m.exclusions = !0)  : '|' === t.charAt(0) && (t = t.substring(1), s = m.ored = !0),
    0 === t.indexOf(d) ? (n = m.exact_matches = !0, t = $.trim(t.replace(new RegExp(d, 'g'), ' ')))  : e || (t = $.trim(j(t))),
    /\s[*?]+\s/.test(' ' + t + ' ') && (t = ''),
    t.length ? (c = R(t, !n), '?' === t.charAt(t.length - 1) && (n = !0), r = l + c + (n ? o : ''), i = '[|](' + c + ')([|])([0-9]?)', {
      raw_term: t,
      term: c,
      regex: new RegExp(l + '(' + c + ')' + (n ? o : '(.)?'), 'ig'),
      keyword_regex: new RegExp(i, 'ig'),
      description_regex_str: r,
      description_regex: new RegExp(r, 'ig'),
      content_exact: 0,
      content_start: 0,
      title_exact: 0,
      title_start: 0,
      indexterm_exact: 0,
      keyword_exact: 0,
      idf_content_exact: 0,
      idf_content_start: 0,
      idf_title_exact: 0,
      idf_title_start: 0,
      idf_indexterm_exact: 0,
      idf_keyword_exact: 0,
      is_excluded: a,
      is_exact: n,
      ored: s,
      whole_term: e
    })  : null
  },
  w = function () {
    var t,
    e,
    r,
    n,
    a,
    i,
    s,
    c,
    o,
    l;
    for ([], s = (i = (a = m.string).split('"')).length, t = 0; t < s; ) t % 2 != 0 && t + 1 < s && (i[t] = $.trim(i[t]), i[t].length && (i[t] = d + i[t].replace(/\s+/g, d))),
    t++;
    for (a = i.join(''), n = null, e = 0, r = (o = (a = $.trim(a.replace(/\s+/g, ' '))).split(' ')).length; e < r; e++) 'AND' !== (c = o[e]) && (!n || 'OR' !== c && '|' !== c && '||' !== c ? null !== (l = b(c, !1)) && (m.terms.push(l), n = l)  : n.ored = m.ored = !0);
    m.terms.length && (m.terms[m.terms.length - 1].ored = !1),
    1 < m.terms.length && !(m.exclusions || m.ored || m.exact_matches) && m.terms.push(b(a, !0))
  },
  C = function (t, e, r, n) {
    var a,
    i,
    s,
    c,
    o,
    l,
    f,
    u,
    d;
    for (o = s = - 1, i = u = 0, f = 0 < n ? r.keyword_regex : r.regex, a = t + e, d = 2 === n ? 1 : Math.round(Math.max(a.length / 6, 1)); null !== (l = f.exec(a)); ) void 0 === l[2] || _.test(l[2]) ? (i++, - 1 === s && (s = l.index), 2 === n && '1' === l[3] && i++)  : (u++, - 1 === o && (o = l.index));
    return (c = - 1 !== s ? s : o) > t.length && (c = - 1),
    {
      tf_exact: i / d,
      tf_start: u / d,
      first_pos: c,
      est_word_count: d
    }
  },
  O = function (t, e, r, n, a) {
    var i,
    s,
    c,
    o,
    l,
    f;
    if (f = C(e, '', t, 0), c = C(r, n + a, t, 0), o = C('', n, t, 1), l = C('', a, t, 2), s = f.tf_exact || c.tf_exact || o.tf_exact || l.tf_exact, i = f.tf_start || c.tf_start || o.tf_start || l.tf_start, t.is_excluded) {
      if (s) return null
    } else {
      if (!i && !s) return null;
      f.tf_exact && t.title_exact++,
      f.tf_start && t.title_start++,
      c.tf_exact && t.content_exact++,
      c.tf_start && t.content_start++,
      o.tf_exact && t.indexterm_exact++,
      l.tf_exact && t.keyword_exact++
    }
    return {
      term: t,
      title: f,
      content: c,
      indexterm: o,
      keyword: l
    }
  },
  i = function (t, e) {
    return 0 === e ? void 0 : e
  },
  s = function (t) {
    var e;
    return e = '',
    t && (e += 'Term: ' + t.term.raw_term + '\n', delete t.term, t.title.tf_exact || t.title.tf_start || delete t.title, t.content.tf_exact || t.content.tf_start || delete t.content, t.indexterm.tf_exact || t.indexterm.tf_start || delete t.indexterm, t.keyword.tf_exact || t.keyword.tf_start || delete t.keyword, e += JSON.stringify(t, i, 2) + '\n'),
    e
  },
  f = function (t) {
    var e,
    r,
    n,
    a,
    i;
    for (i = '<pre class="debug">', i += 'Rank value: ' + t.rank + '\n', e = 0, r = (a = t.matches).length; e < r; e++) n = a[e],
    i += s(n);
    return i + '</pre>'
  },
  u = function () {
    var t,
    e,
    r,
    n,
    a;
    for (n = '<pre class="debug">', n += 'Results: ' + p.length + ' out of ' + g.length() + ' topics\n', n += 'Terms\n', t = 0, e = (r = m.terms).length; t < e; t++) a = r[t],
    n += JSON.stringify(a, i, 2);
    return n + '</pre>'
  },
  q = function (t) {
    var e,
    r,
    n,
    a,
    i,
    s,
    c,
    o,
    l,
    f,
    u,
    d,
    _,
    h,
    g;
    for (g = t[0], h = t[1], e = t[2], n = k(e, 0), a = 3 < t.length ? t[3] : '', s = 4 < t.length ? t[4] : '', r = - 1, f = u = !(l = [
    ]), i = 0, c = (d = m.terms).length; i < c; i++) {
      if (_ = d[i], o = O(_, h, e, a, s), !0 === _.ored) u = !0,
      null !== o && (f = !0);
       else if (!0 === u) {
        if (!f && null === o) return;
        u = f = !1
      } else if (null === o && !1 === _.whole_term) return;
      null !== o && (_.is_excluded || (r = - 1 !== r ? Math.min(o.content.first_pos, r)  : o.content.first_pos), l.push(o))
    }
    0 !== l.length && (x < r && (n = k(e, r)), p.push({
      title: h,
      url: g,
      description: n.length ? n : h,
      matches: l
    }))
  },
  y = function (t) {
    var e,
    r,
    n,
    a,
    i,
    s,
    c;
    return e = t.term,
    s = 30 * t.title.tf_exact * e.idf_title_exact,
    c = 3 * t.title.tf_start * e.idf_title_start,
    r = 1 * t.content.tf_exact * e.idf_content_exact,
    n = 0.1 * t.content.tf_start * e.idf_content_start,
    a = 5 * t.indexterm.tf_exact * e.idf_indexterm_exact,
    i = 30 * t.keyword.tf_exact * e.idf_keyword_exact,
    h && (s && (t.title.tfidf_exact = s), c && (t.title.tfidf_start = c), r && (t.content.tfidf_exact = r), n && (t.content.tfidf_start = n), a && (t.indexterm.tfidf_exact = a), i && (t.keyword.tfidf_exact = i)),
    s + c + r + n + a + i
  },
  v = function (t) {
    var e,
    r,
    n,
    a,
    i;
    for (e = i = 0, r = (a = t.matches).length; e < r; e++) n = a[e],
    i += y(n);
    return i
  },
  T = function () {
    var t,
    e,
    r,
    n,
    a,
    i,
    s,
    c,
    o,
    l,
    f,
    u,
    d,
    _,
    h;
    p = [
    ];
    try {
      w()
    } catch (t) {
      return void t
    }
    if (m.terms.length) {
      for (t = 0, n = (o = g.data).length; t < n; t++) for (e = 0, a = (u = o[t]).length; e < a; e++) _ = u[e],
      q(_);
      for (m.terms.sort(function (t, e) {
        return e.is_excluded ? 1 : - 1
      }); m.terms.length && m.terms[0].is_excluded; ) m.terms.shift();
      for (h = g.length(), r = 0, i = (l = m.terms).length; r < i; r++) (d = l[r]).idf_content_exact = 0 === d.content_exact ? 0 : Math.log(h / d.content_exact),
      d.idf_content_start = 0 === d.content_start ? 0 : Math.log(h / (d.content_start + d.content_exact)),
      d.idf_title_exact = 0 === d.title_exact ? 0 : Math.log(h / d.title_exact),
      d.idf_title_start = 0 === d.title_start ? 0 : Math.log(h / (d.title_start + d.title_exact)),
      d.idf_indexterm_exact = 0 === d.indexterm_exact ? 0 : Math.log(h / d.indexterm_exact),
      d.idf_keyword_exact = 0 === d.keyword_exact ? 0 : Math.log(h / d.keyword_exact);
      for (c = 0, s = p.length; c < s; c++) (f = p[c]).rank = v(f);
      0 < p.length && p.sort(function (t, e) {
        return t.rank < e.rank ? 1 : t.rank > e.rank ? - 1 : 0
      })
    }
    return !0
  },
  a = function () {
    var t,
    e,
    r,
    n,
    a,
    i,
    s,
    c,
    o,
    l;
    for (T(), o = [
    ], i = Math.min(100, p.length), p.length = i, h && o.push(u()), e = 0, n = p.length; e < n; e++) {
      for (c = p[e], t = A(c.description), r = 0, a = (s = m.terms).length; r < a; r++) l = s[r],
      t = t.replace(l.description_regex, function (t) {
        return '<b>' + t + '</b>'
      });
      o.push('<div class="result">'),
      o.push('<a href="', c.url, '">', c.title, '</a>'),
      1 < t.length && o.push('<p>', t, '</p>'),
      h && o.push(f(c)),
      o.push('</div>')
    }
    return o.join('')
  },
  I = function (e) {
    var r,
    n;
    return h = e.shiftKey,
    m.terms = [
    ],
    m.string = $.trim(document.getElementById('query').value.replace(/\s+/g, ' ')),
    m.exclusions = !1,
    m.exact_matches = !1,
    m.string && (r = $('#results'), (n = $('#summary')).removeClass().addClass('str-searching'), r.fadeOut(function () {
      try {
        return r.html(a()),
        n.removeClass('str-searching'),
        r.fadeIn(function () {
          if (!p.length) return n.addClass('str-search-empty')
        })
      } catch (t) {
        return e = t,
        r.html(''),
        n.attr('class', 'str-search-error')
      }
    })),
    !1
  },
  D = function (t) {
    var e,
    r,
    n,
    a,
    i;
    if (i = [
    ], E === t) {
      for (r = 0, n = (a = m.terms).length; r < n; r++) e = a[r],
      i.push(e.description_regex_str);
      i.length && H('topicwin', 'highlight', t, i.join('[!!]'))
    }
    E = null
  },
  L = function () {
    var t,
    e;
    void 0 === L.called && (L.called = !0, $('base').remove(), (e = $('#search')).html('<div>\n  <form action="#" name="form" id="form">\n    <input type="text" id="query" name="query" autofocus="true" inputmode="text" required="true">\n    <input type="button" id="submit" name="submit" value="Search">\n  </form>\n</div>\n<div id="summary"/>\n<div id="results"/>'), e.on('click', '#submit', I), e.on('keypress', '#query', function (t) {
      if (13 === t.which) return I(t)
    }), self !== parent && e.on('click', '.result > a', function () {
      return N('loadTopic', this.href),
      E = this.href,
      !1
    }), (t = n('q')) && ($('#query').val(decodeURIComponent(t)), $('#submit').click()))
  },
  P = function (t) {
    var e;
    (e = document.getElementById('bar')) && (e.style.width = t),
    '100%' === t && L()
  },
  t(function (t, e) {
    switch (t) {
      case 'topicLoaded':
        D(e[0]);
        break;
      case 'searchLoad':
        P(e[0])
    }
  }), 'undefined' != typeof SEARCH_DATA ? g = SEARCH_DATA : (g = {
    data: [
      SearchArray
    ]
  }, L()), g.length = function () {
    var t,
    e,
    r,
    n;
    for (t = e = 0, r = (n = this.data).length; t < r; t++) e += n[t].length;
    return e
  }
}).call(this);
