import { defineComponent, h } from 'vue';
import { getIconSvgPaintProps, mergeClasses, iconNodeElementAttrs } from '@opudoc/opicon-shared';

const renderNode = (node, filled) => {
  if (node.length === 3) {
    const [tag2, attrs2, children] = node;
    const { key: key2, ...rest2 } = iconNodeElementAttrs(tag2, attrs2, filled);
    return h(tag2, { key: key2, ...rest2 }, children.map((child) => renderNode(child, filled)));
  }
  const [tag, attrs] = node;
  const { key, ...rest } = iconNodeElementAttrs(tag, attrs, filled);
  return h(tag, { key, ...rest });
};
const Icon = defineComponent({
  name: "OpiconIcon",
  props: {
    iconNode: { type: Array, required: true },
    size: { type: [Number, String], default: 24 },
    color: { type: String, default: "currentColor" },
    strokeWidth: { type: [Number, String], default: 2 },
    absoluteStrokeWidth: { type: Boolean, default: false },
    class: { type: String, default: "" }
  },
  setup(props, { attrs }) {
    return () => {
      const paint = getIconSvgPaintProps(props.iconNode, {
        color: props.color,
        strokeWidth: props.strokeWidth,
        absoluteStrokeWidth: props.absoluteStrokeWidth,
        size: props.size
      });
      return h(
        "svg",
        {
          xmlns: "http://www.w3.org/2000/svg",
          width: props.size,
          height: props.size,
          viewBox: "0 0 24 24",
          color: paint.color,
          fill: paint.fill,
          stroke: paint.stroke,
          ...paint.strokeWidth !== void 0 && { strokeWidth: paint.strokeWidth },
          class: mergeClasses("opicon", props.class),
          "aria-hidden": true,
          ...attrs
        },
        props.iconNode.map((node) => renderNode(node, paint.filled))
      );
    };
  }
});

export { Icon as default };
//# sourceMappingURL=Icon.mjs.map
