import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.json';

const uniqueNames = {};

vtkColorMaps
  .filter((p) => p.RGBPoints)
  .filter((p) => p.ColorSpace !== 'CIELAB')
  .map((p) => p.Name)
  .forEach((name) => {
    uniqueNames[name] = true;
  });

// ----------------------------------------------------------------------------

const rgbPresetNames = Object.keys(uniqueNames);
rgbPresetNames.sort();

// ----------------------------------------------------------------------------

function getPresetByName(name) {
  return vtkColorMaps.find((p) => p.Name === name);
}

// ----------------------------------------------------------------------------

export default {
  getPresetByName,
  rgbPresetNames,
};

@@ -99,24 +99,39 @@
 nst 
-uniqueNames = %7B%7D
+presetMap = Object.create(null)
 ;%0A%0Av
@@ -220,30 +220,8 @@
 B')%0A
-  .map((p) =%3E p.Name)%0A
   .f
@@ -228,20 +228,17 @@
 orEach((
-name
+p
 ) =%3E %7B%0A 
@@ -244,32 +244,29 @@
     
-uniqueNames%5Bn
+presetMap%5Bp.N
 ame%5D = 
-true
+p
 ;%0A  
@@ -390,19 +390,17 @@
 eys(
-uniqueNames
+presetMap
 );%0Ar
@@ -549,49 +549,605 @@
 urn 
-vtkColorMaps.find((p) =%3E p.Name === name)
+presetMap%5Bname%5D;%0A%7D%0A%0A// ----------------------------------------------------------------------------%0A%0Afunction addPreset(preset) %7B%0A  if (!preset.RGBPoints %7C%7C preset.ColorSpace === 'CIELAB') %7B%0A    return;%0A  %7D%0A%0A  if (!presetMap%5Bpreset.Name%5D) %7B%0A    rgbPresetNames.push(preset.Name);%0A    rgbPresetNames.sort();%0A  %7D%0A%0A  presetMap%5Bpreset.Name%5D = preset;%0A%7D%0A%0A// ----------------------------------------------------------------------------%0A%0Afunction removePresetByName(name) %7B%0A  const index = rgbPresetNames.indexOf(name);%0A  if (index %3E -1) %7B%0A    rgbPresetNames.splice(index, 1);%0A  %7D%0A  delete presetMap%5Bname%5D
 ;%0A%7D%0A
@@ -1245,16 +1245,51 @@
 fault %7B%0A
+  addPreset,%0A  removePresetByName,%0A
   getPre

Support adding and removing presets