{"version":3,"sources":["jsdelivr-header.js","/npm/@thi.ng/pixel-dominant-colors@2.0.46/utils.js","/npm/@thi.ng/pixel-dominant-colors@2.0.46/kmeans.js","/npm/@thi.ng/pixel-dominant-colors@2.0.46/mean-cut.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,sRCNA,MAAM,EAAgB,CAAC,EAAM,KAC3B,MAAM,EAAU,GAChB,IAAI,EAAI,EACR,IAAK,MAAM,KAAK,EACV,EAAK,EAAG,IAAI,EAAQ,KAAK,GAC7B,IAEF,OAAO,GCLH,EAAuB,CAAC,EAAK,EAAK,KACtC,MAAM,EAAU,GAAM,OAAS,EAAc,EAAK,OAAQ,GAAO,MAAM,QAAQ,GAAO,EAAM,IAAI,GAChG,OAAO,EAAQ,OAAS,EAAO,KAAK,IAAI,EAAK,EAAQ,QAAS,EAAS,GAAM,KAAK,CAAC,EAAG,IAAM,EAAE,MAAM,OAAS,EAAE,MAAM,QAAQ,IAC1H,IAAC,CACA,MAAO,IAAI,EAAE,UACb,KAAM,EAAE,MAAM,OAAS,EAAQ,OAC/B,IAAK,EAAE,SAEP,ICNA,EAAwB,CAAC,EAAK,EAAK,IAAS,EAAiB,EAAO,EAAK,EAAK,GAC9E,EAA0B,CAAC,EAAK,EAAK,IAAS,EAAiB,EAAS,EAAK,EAAK,GAClF,EAAmB,CAAC,EAAK,EAAK,EAAK,KACvC,MAAM,EAAU,GAAM,OAAS,EAAc,EAAK,OAAQ,GAAO,IAAI,GACrE,OAAO,EAAQ,OAAS,EAAe,EAAK,EAAS,EAAQ,GAAG,OAAQ,GAAK,KAAK,CAAC,EAAG,IAAM,EAAE,OAAS,EAAE,QAAQ,IAC9G,IAAG,CACF,MAAO,EAAK,GAAI,GAChB,KAAM,EAAI,OAAS,EAAQ,UAE3B,W","file":"/npm/@thi.ng/pixel-dominant-colors@2.0.46/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.48.0.\n * Original file: /npm/@thi.ng/pixel-dominant-colors@2.0.46/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","const filterSamples = (pred, img) => {\n  const samples = [];\n  let i = 0;\n  for (const p of img) {\n    if (pred(p, i)) samples.push(p);\n    i++;\n  }\n  return samples;\n};\nexport {\n  filterSamples\n};\n","import { kmeans } from \"@thi.ng/k-means/kmeans\";\nimport { filterSamples } from \"./utils.js\";\nconst dominantColorsKmeans = (img, num, opts) => {\n  const samples = opts?.filter ? filterSamples(opts.filter, img) : Array.isArray(img) ? img : [...img];\n  return samples.length ? kmeans(Math.min(num, samples.length), samples, opts).sort((a, b) => b.items.length - a.items.length).map(\n    (c) => ({\n      color: [...c.centroid],\n      area: c.items.length / samples.length,\n      ids: c.items\n    })\n  ) : [];\n};\nexport {\n  dominantColorsKmeans\n};\n","import { computeCutWith } from \"@thi.ng/k-means/mean-cut\";\nimport { mean, vmean } from \"@thi.ng/vectors/mean\";\nimport { vmedian } from \"@thi.ng/vectors/median\";\nimport { filterSamples } from \"./utils.js\";\nconst dominantColorsMeanCut = (img, num, opts) => __dominantColors(vmean, img, num, opts);\nconst dominantColorsMedianCut = (img, num, opts) => __dominantColors(vmedian, img, num, opts);\nconst __dominantColors = (cut, img, num, opts) => {\n  const samples = opts?.filter ? filterSamples(opts.filter, img) : [...img];\n  return samples.length ? computeCutWith(cut, samples, samples[0].length, num).sort((a, b) => b.length - a.length).map(\n    (bin) => ({\n      color: mean([], bin),\n      area: bin.length / samples.length\n    })\n  ) : [];\n};\nexport {\n  dominantColorsMeanCut,\n  dominantColorsMedianCut\n};\n"]}