{"version":3,"sources":["jsdelivr-header.js","/npm/in-memory-faceted-search@1.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACJA,SAAS,YAAW,KAAE,EAAI,OAAE,EAAM,aAAE,EAAY,SAAE,IAChD,MAAM,EAAQ,CAAC,EACf,IAAK,MAAM,KAAQ,EAAM,CAEvB,MAAM,EADK,UAAU,CAAE,IAAK,EAAM,SAAQ,eAAc,aAE1D,CACA,OAAO,CACT,CAEA,SAAS,WAAU,IAAE,EAAG,OAAE,EAAM,YAAE,EAAc,GAAE,aAAE,EAAe,GAAE,SAAE,SAC7C,IAAb,IAEP,EADE,EAAa,OAAS,EACb,EAAa,OAEb,GAGf,MAAM,EAAO,CAAE,MAAO,GAEtB,IAAK,MAAM,KAAK,EAAQ,CACtB,MAAM,EAAQ,EAAE,IAAM,EAAE,IAAI,GAAO,EAAI,EAAE,OACzC,IAA+B,GAA3B,EAAY,QAAQ,GAAU,CAChC,EAAY,KAAK,GACjB,IAAI,EAAQ,EAAY,QAAU,EAClC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAY,QAAU,EAAI,EAAa,OAAQ,IAC7D,EAAa,KAAO,EAAY,GAAG,OACrC,GAAQ,GAGR,IACF,EAAK,EAAE,MAAQ,CACb,CAAC,GAAQ,CAAE,MAAO,IAEhB,IACF,EAAK,EAAE,MAAM,GAAS,UAAU,CAAE,MAAK,SAAQ,cAAa,eAAc,eAG9E,EAAY,KACd,CACF,CACA,OAAO,CACT,CAEA,SAAS,MAAM,EAAa,GAC1B,IAAK,MAAM,KAAK,EACW,iBAAd,EAAO,KACX,EAAY,KACf,EAAY,GAAK,CAAC,GAEpB,MAAM,EAAY,GAAI,EAAO,KAEN,iBAAd,EAAO,KACX,EAAY,GAGf,EAAY,IAAM,EAAO,GAFzB,EAAY,GAAK,EAAO,GAMhC,CA7DA,OAAO,QAAU","file":"/npm/in-memory-faceted-search@1.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/in-memory-faceted-search@1.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","module.exports = buildIndex\n\nfunction buildIndex({ data, facets, selectedPath, maxLevel }) {\n  const index = {}\n  for (const item of data) {\n    let tree = buildTree({ obj: item, facets, selectedPath, maxLevel })\n    merge(index, tree)\n  }\n  return index\n}\n\nfunction buildTree({ obj, facets, currentPath = [], selectedPath = [], maxLevel }) {\n  if (typeof maxLevel === \"undefined\") {\n    if (selectedPath.length > 0) {\n      maxLevel = selectedPath.length\n    } else {\n      maxLevel = 1\n    }\n  }\n  const tree = { count: 1 }\n\n  for (const f of facets) {\n    const value = f.map ? f.map(obj) : obj[f.field]\n    if (currentPath.indexOf(f) == -1) { // Facet not added yet\n      currentPath.push(f)\n      let match = currentPath.length <= maxLevel\n      for (let i = 0; i < currentPath.length && i < selectedPath.length; i++) {\n        if (selectedPath[i] !== currentPath[i].name) {\n          match = false\n        }\n      }\n      if (match) {\n        tree[f.name] = {\n          [value]: { count: 1 }\n        }\n        if (match) {\n          tree[f.name][value] = buildTree({ obj, facets, currentPath, selectedPath, maxLevel })\n        }\n      }\n      currentPath.pop()\n    }\n  }\n  return tree\n}\n\nfunction merge(destination, source) {\n  for (const k in source) {\n    if (typeof source[k] === \"object\") {\n      if (!destination[k]) {\n        destination[k] = {}\n      }\n      merge(destination[k], source[k])\n    }\n    if (typeof source[k] === \"number\") {\n      if (!destination[k]) {\n        destination[k] = source[k]\n      } else {\n        destination[k] += source[k]\n      }\n    }\n  }\n}\n"]}