{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_search.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","formatSearchResultItem","item","terms","ref","doc","title","body","stemmedTerms","map","w","elasticlunr","stemmer","toLowerCase","termFound","index","weighted","sentences","split","words","j","word","length","k","startsWith","push","windowWeights","windowSize","Math","min","curSum","maxSumIndex","maxFound","teaser","startIndex","substring","join","makeTeaser","initSearch","func","wait","timeout","$searchInput","document","getElementById","$searchResults","querySelector","$searchResultsItems","options","bool","fields","boost","Index","load","window","searchIndex","addEventListener","term","trim","style","display","innerHTML","results","search","createElement","appendChild","context","this","args","arguments","clearTimeout","setTimeout","apply","readyState","documentElement","doScroll"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAA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BC,EAAMC,EAClBC,EAkIAC,EAAeC,SAASC,eAAe,UACvCC,EAAiBF,SAASG,cAAc,mBACxCC,EAAsBJ,SAASG,cAAc,0BAG7CE,EAAU,CACZC,KAAM,MACNC,OAAQ,CACN5C,MAAO,CACL6C,MAAO,GAET5C,KAAM,CACJ4C,MAAO,KAKTpC,EAAQJ,YAAYyC,MAAMC,KAAKC,OAAOC,aAE1Cb,EAAac,iBAAiB,SAtJdjB,EAsJgC,WAC9C,IAAIkB,EAAOf,EAAaxD,MAAMwE,OAC9B,GAAK3C,IAGL8B,EAAec,MAAMC,QAAmB,KAATH,EAAc,OAAS,QACtDV,EAAoBc,UAAY,GACnB,KAATJ,GAAJ,CAIA,IAAIK,EAAU/C,EAAMgD,OAAON,EAAMT,GACjC,GAAuB,IAAnBc,EAAQxC,OAAZ,CAKcmC,EACd,IAAK,IAAIxF,EAAI,EAAGA,EAAI2D,KAAKC,IAAIiC,EAAQxC,OAlCvB,IAkC2CrD,IAAK,CAC5D,IAAIiC,EAAOyC,SAASqB,cAAc,MAClC9D,EAAK2D,UAAY5D,EAAuB6D,EAAQ7F,GAAIwF,EAAKvC,MAAM,MAC/D6B,EAAoBkB,YAAY/D,SARhC2C,EAAec,MAAMC,QAAU,SAnKbpB,EA6KnB,IA1KI,WACL,IAAI0B,EAAUC,KACVC,EAAOC,UACXC,aAAa7B,GAEbA,EAAU8B,YAAW,WACnB9B,EAAU,KACVF,EAAKiC,MAAMN,EAASE,KACnB5B,MAsKqB,aAAxBG,SAAS8B,YACc,YAAxB9B,SAAS8B,aAA6B9B,SAAS+B,gBAAgBC,SAEhErC,IAEAK,SAASa,iBAAiB,mBAAoBlB","file":"zulma_search.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/* eslint-disable */\n\nfunction debounce(func, wait) {\n var timeout;\n\n return function () {\n var context = this;\n var args = arguments;\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n timeout = null;\n func.apply(context, args);\n }, wait);\n };\n}\n\n// Taken from mdbook\n// The strategy is as follows:\n// First, assign a value to each word in the document:\n// Words that correspond to search terms (stemmer aware): 40\n// Normal words: 2\n// First word in a sentence: 8\n// Then use a sliding window with a constant number of words and count the\n// sum of the values of the words within the window. Then use the window that got the\n// maximum sum. If there are multiple maximas, then get the last one.\n// Enclose the terms in .\nfunction makeTeaser(body, terms) {\n var TERM_WEIGHT = 40;\n var NORMAL_WORD_WEIGHT = 2;\n var FIRST_WORD_WEIGHT = 8;\n var TEASER_MAX_WORDS = 30;\n\n var stemmedTerms = terms.map(function (w) {\n return elasticlunr.stemmer(w.toLowerCase());\n });\n var termFound = false;\n var index = 0;\n var weighted = []; // contains elements of [\"word\", weight, index_in_document]\n\n // split in sentences, then words\n var sentences = body.toLowerCase().split(\". \");\n\n for (var i in sentences) {\n var words = sentences[i].split(\" \");\n var value = FIRST_WORD_WEIGHT;\n\n for (var j in words) {\n var word = words[j];\n\n if (word.length > 0) {\n for (var k in stemmedTerms) {\n if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {\n value = TERM_WEIGHT;\n termFound = true;\n }\n }\n weighted.push([word, value, index]);\n value = NORMAL_WORD_WEIGHT;\n }\n\n index += word.length;\n index += 1; // ' ' or '.' if last word in sentence\n }\n\n index += 1; // because we split at a two-char boundary '. '\n }\n\n if (weighted.length === 0) {\n return body;\n }\n\n var windowWeights = [];\n var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);\n // We add a window with all the weights first\n var curSum = 0;\n for (var i = 0; i < windowSize; i++) {\n curSum += weighted[i][1];\n }\n windowWeights.push(curSum);\n\n for (var i = 0; i < weighted.length - windowSize; i++) {\n curSum -= weighted[i][1];\n curSum += weighted[i + windowSize][1];\n windowWeights.push(curSum);\n }\n\n // If we didn't find the term, just pick the first window\n var maxSumIndex = 0;\n if (termFound) {\n var maxFound = 0;\n // backwards\n for (var i = windowWeights.length - 1; i >= 0; i--) {\n if (windowWeights[i] > maxFound) {\n maxFound = windowWeights[i];\n maxSumIndex = i;\n }\n }\n }\n\n var teaser = [];\n var startIndex = weighted[maxSumIndex][2];\n for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {\n var word = weighted[i];\n if (startIndex < word[2]) {\n // missing text from index to start of `word`\n teaser.push(body.substring(startIndex, word[2]));\n startIndex = word[2];\n }\n\n // add around search terms\n if (word[1] === TERM_WEIGHT) {\n teaser.push(\"\");\n }\n startIndex = word[2] + word[0].length;\n teaser.push(body.substring(word[2], startIndex));\n\n if (word[1] === TERM_WEIGHT) {\n teaser.push(\"\");\n }\n }\n teaser.push(\"…\");\n return teaser.join(\"\");\n}\n\nfunction formatSearchResultItem(item, terms) {\n return '
' +\n `${item.doc.title}` +\n `
${makeTeaser(item.doc.body, terms)}
` +\n '
';\n}\n\nfunction initSearch() {\n var $searchInput = document.getElementById(\"search\");\n var $searchResults = document.querySelector(\".search-results\");\n var $searchResultsItems = document.querySelector(\".search-results__items\");\n var MAX_ITEMS = 10;\n\n var options = {\n bool: \"AND\",\n fields: {\n title: {\n boost: 2\n },\n body: {\n boost: 1\n },\n }\n };\n var currentTerm = \"\";\n var index = elasticlunr.Index.load(window.searchIndex);\n\n $searchInput.addEventListener(\"keyup\", debounce(function () {\n var term = $searchInput.value.trim();\n if (!index) {\n return;\n }\n $searchResults.style.display = term === \"\" ? \"none\" : \"block\";\n $searchResultsItems.innerHTML = \"\";\n if (term === \"\") {\n return;\n }\n\n var results = index.search(term, options);\n if (results.length === 0) {\n $searchResults.style.display = \"none\";\n return;\n }\n\n currentTerm = term;\n for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {\n var item = document.createElement(\"li\");\n item.innerHTML = formatSearchResultItem(results[i], term.split(\" \"));\n $searchResultsItems.appendChild(item);\n }\n }, 150));\n}\n\n\nif (document.readyState === \"complete\" ||\n (document.readyState !== \"loading\" && !document.documentElement.doScroll)\n) {\n initSearch();\n} else {\n document.addEventListener(\"DOMContentLoaded\", initSearch);\n}"],"sourceRoot":""}