import { redrawWatchedIcons } from './library.mjs';

const notDefined = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" class="flow-ui-icon"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M64 390.3L153.5 256 64 121.7v268.6zm38.5 57.7h179L192 313.7 102.5 448zm128-192L320 390.3V121.7L230.5 256zm51-192h-179L192 198.3 281.5 64zM0 48C0 21.5 21.5 0 48 0h288c26.5 0 48 21.5 48 48v416c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V48z"/></svg>'
)}`;
const iconMap = /* @__PURE__ */ new Map();
const addIcons = (icons) => {
  Object.keys(icons).forEach((name) => {
    addToIconMap(name, icons[name]);
    const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, "$1-$2").toLowerCase();
    if (name !== toKebabCase) {
      addToIconMap(toKebabCase, icons[name]);
    }
  });
  redrawWatchedIcons();
};
const addToIconMap = (name, data) => {
  const map = getIconMap();
  const existingIcon = map.get(name);
  if (existingIcon === void 0) {
    map.set(name, data);
  } else if (existingIcon !== data) {
    console.warn(
      `flow-rdf-ui: Multiple icons were mapped to name "${name}". Ensure that multiple icons are not mapped to the same icon name.`
    );
  }
};
const getIconMap = () => iconMap;
const library = {
  name: "default",
  resolver: (name) => {
    const map = getIconMap();
    const icon = map.get(name);
    return icon ?? notDefined;
  }
};

export { addIcons, getIconMap, library };
