{"version":3,"file":"index.mjs","sources":["../src/utils/index.js","../src/components/Icon.js","../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["const ESCAPE_MAP = {\n  \"<\": \"&lt;\",\n  \">\": \"&gt;\",\n  '\"': \"&quot;\",\n  \"'\": \"&#039;\",\n  \"&\": \"&amp;\"\n};\n\nconst escapeHTML = (html) => {\n  return html.replace(/[<>\"&]/g, (c) => ESCAPE_MAP[c] || c);\n};\n\nlet id_count = 0;\n\nconst getID = (prefix) => {\n  return prefix + id_count++;\n};\n\nexport default {\n  escapeHTML,\n  getID\n};\n","import Vue from 'vue'\nimport utils from \"../utils\";\n\nconst icons = {};\n\nconst register = (data) => {\n  const { name, paths = [], d, polygons = [], points } = data;\n\n  if (d) paths.push({ d });\n  if (points) polygons.push({ points });\n\n  icons[name] = Object.assign({}, data, {\n    paths,\n    polygons\n  });\n\n  if (!icons[name].minX) icons[name].minX = 0;\n  if (!icons[name].minY) icons[name].minY = 0;\n};\n\nconst addIcons = (...data) => {\n  for (const icon of data) register(icon);\n};\n\nconst OhVueIcon = Vue.component('OhVueIcon', {\n  name: 'OhVueIcon',\n  props: {\n    name: {\n      type: String,\n      validator: function (val) {\n        if (val && !(val in icons)) {\n          console.warn(`Invalid prop: prop \"name\" is referring to an unregistered icon \"${val}\".\\n` +\n            `Please make sure you have imported this icon before using it.`);\n          return false;\n        }\n        return true;\n      }\n    },\n    title: String,\n    fill: String,\n    scale: {\n      type: [Number, String],\n      default: 1\n    },\n    animation: {\n      validator: (val) => {\n        return [\n          \"spin\",\n          \"spin-pulse\",\n          \"wrench\",\n          \"ring\",\n          \"pulse\",\n          \"flash\",\n          \"float\"\n        ].includes(val);\n      }\n    },\n    hover: Boolean,\n    flip: {\n      validator: (val) => {\n        return [\"horizontal\", \"vertical\", \"both\"].includes(val);\n      }\n    },\n    speed: {\n      validator: (val) => {\n        return val === \"fast\" || val === \"slow\";\n      }\n    },\n    label: String,\n    inverse: Boolean\n  },\n  data() {\n    return {\n      children: [],\n      outerScale: 1.2,\n      x: null,\n      y: null\n    };\n  },\n  computed: {\n    normalizedScale() {\n      const scale = Number(this.scale);\n      if (isNaN(scale) || scale <= 0) {\n        console.warn(`Invalid prop: prop \"scale\" should be a number over 0.`);\n        return this.outerScale;\n      }\n      return scale * this.outerScale;\n    },\n    icon() {\n      return icons[this.name];\n    },\n    box() {\n      const icon = this.icon;\n      if (icon) {\n        return `${icon.minX} ${icon.minY} ${icon.width} ${icon.height}`;\n      }\n      return `0 0 ${this.width} ${this.height}`;\n    },\n    raw() {\n      // Generates unique id for each icon's SVG element with ID\n      if (!this.icon || !this.icon.raw) return null;\n\n      const ids = {};\n      let raw = this.icon.raw;\n\n      raw = raw.replace(\n        /\\s(?:xml:)?id=([\"']?)([^\"')\\s]+)\\1/g,\n        (match, quote, id) => {\n          const uniqueId = utils.getID(\"vat-\");\n          ids[id] = uniqueId;\n          return ` id=\"${uniqueId}\"`;\n        }\n      );\n      raw = raw.replace(\n        /#(?:([^'\")\\s]+)|xpointer\\(id\\((['\"]?)([^')]+)\\2\\)\\))/g,\n        (match, rawId, _, pointerId) => {\n          const id = rawId || pointerId;\n          if (!id || !ids[id]) return match;\n          return `#${ids[id]}`;\n        }\n      );\n      return raw;\n    },\n    ratio() {\n      const icon = this.icon;\n      if (!icon) return 1;\n      return Math.max(icon.width, icon.height) / 16;\n    },\n    width() {\n      return this.icon ? (this.icon.width / this.ratio) * this.normalizedScale : 0;\n    },\n    height() {\n      return this.icon ? (this.icon.height / this.ratio) * this.normalizedScale : 0;\n    },\n    style() {\n      if (this.normalizedScale === 1) return {};\n      return {\n        fontSize: this.normalizedScale + 'em'\n      };\n    },\n    klass() {\n      return {\n        'ov-icon': true,\n        'ov-inverse': this.inverse,\n        'ov-flip-horizontal': this.flip === 'horizontal',\n        'ov-flip-vertical': this.flip === 'vertical',\n        'ov-flip-both': this.flip === 'both',\n        'ov-spin': this.animation === 'spin',\n        'ov-spin-pulse': this.animation === 'spin-pulse',\n        'ov-wrench': this.animation === 'wrench',\n        'ov-ring': this.animation === 'ring',\n        'ov-pulse': this.animation === 'pulse',\n        'ov-flash': this.animation === 'flash',\n        'ov-float': this.animation === 'float',\n        'ov-hover': this.hover,\n        'ov-fast': this.speed === 'fast',\n        'ov-slow': this.speed === 'slow'\n      };\n    },\n    attribs() {\n      if (!this.icon || !this.icon.attr) return {};\n      return this.icon.attr;\n    }\n  },\n  methods: {\n    updateStack() {\n      if (!this.name && this.name !== null && this.children.length === 0) {\n        console.warn(`Invalid prop: prop \"name\" is required.`);\n        return;\n      }\n\n      if (this.icon) return;\n\n      let width = 0, height = 0;\n      this.children.forEach((child) => {\n        child.outerScale = this.normalizedScale;\n        width = Math.max(width, child.width);\n        height = Math.max(height, child.height);\n      });\n\n      this.children.forEach((child) => {\n        child.x = (width - child.width) / 2;\n        child.y = (height - child.height) / 2;\n      });\n    }\n  },\n  mounted() {\n    this.updateStack();\n  },\n  updated() {\n    this.updateStack();\n  },\n  render() {\n    const attrs = Object.assign(\n      {\n        role: this.$attrs.role || (this.label || this.title ? \"img\" : null),\n        \"aria-label\": this.label || null,\n        \"aria-hidden\": !(this.label || this.title),\n        width: this.width,\n        height: this.height,\n        viewBox: this.box\n      },\n      this.attribs\n    );\n  \n    if (this.attribs.stroke) {\n      attrs.stroke = this.fill ? this.fill : \"currentColor\";\n    } else {\n      attrs.fill = this.fill ? this.fill : \"currentColor\";\n    }\n  \n    if (this.x) attrs.x = this.x.toString();\n    if (this.y) attrs.y = this.y.toString();\n  \n    let options = {\n      class: this.klass,\n      style: this.style,\n      attrs: attrs\n    };\n  \n    if (this.raw) {\n      const html = this.title\n        ? `<title>${this.escapeHTML(this.title)}</title>${this.raw}`\n        : this.raw;\n      options.domProps = { innerHTML: html };\n    }\n  \n    const content = this.title ? [this.$createElement(\"title\", this.title)] : [];\n  \n    const createSVGElement = (name, value, i) => {\n      return this.$createElement(name, {\n        attrs: value,\n        key: `${name}-${i}`\n      });\n    };\n  \n    return this.$createElement(\n      \"svg\",\n      options,\n      this.raw\n        ? undefined\n        : content.concat(\n            this.$slots.default || \n            (this.icon ? [\n              ...this.icon.paths.map((path, i) => createSVGElement(\"path\", path, i)),\n              ...this.icon.polygons.map((polygon, i) => createSVGElement(\"polygon\", polygon, i))\n            ] : [])\n        ))\n  }\n});\n\n\nexport { OhVueIcon, addIcons };","function styleInject(css, ref) {\n  if ( ref === void 0 ) ref = {};\n  var insertAt = ref.insertAt;\n\n  if (!css || typeof document === 'undefined') { return; }\n\n  var head = document.head || document.getElementsByTagName('head')[0];\n  var style = document.createElement('style');\n  style.type = 'text/css';\n\n  if (insertAt === 'top') {\n    if (head.firstChild) {\n      head.insertBefore(style, head.firstChild);\n    } else {\n      head.appendChild(style);\n    }\n  } else {\n    head.appendChild(style);\n  }\n\n  if (style.styleSheet) {\n    style.styleSheet.cssText = css;\n  } else {\n    style.appendChild(document.createTextNode(css));\n  }\n}\n\nexport default styleInject;\n"],"names":["id_count","utils","prefix","icons","register","data","name","paths","d","polygons","points","push","Object","assign","minX","minY","addIcons","icon","OhVueIcon","Vue","component","props","type","String","validator","val","title","fill","scale","Number","default","animation","includes","hover","Boolean","flip","speed","label","inverse","children","outerScale","x","y","computed","normalizedScale","this","isNaN","box","width","height","raw","ids","replace","match","quote","id","uniqueId","rawId","_","pointerId","ratio","Math","max","style","fontSize","klass","attribs","attr","methods","updateStack","length","forEach","child","mounted","updated","render","attrs","role","$attrs","viewBox","stroke","toString","options","class","html","escapeHTML","domProps","innerHTML","content","$createElement","createSVGElement","value","i","key","concat","$slots","map","path","polygon","styleInject","css","ref","insertAt","document","head","getElementsByTagName","createElement","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"mBAYA,IAAIA,EAAW,EAMf,IAAeC,EAJAC,GACNA,EAASF,ICZlB,MAAMG,EAAQ,CAAA,EAERC,EAAYC,IACV,MAAAC,KAAEA,EAAMC,MAAAA,EAAQ,GAACC,EAAGA,WAA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