'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var svg = require('@element-plus/icons-vue');
var font_2298093_rnp72ifj3ba = require('./fontts/font_2298093_rnp72ifj3ba.js');
var fontAwesome = require('./fontts/font-awesome.js');

function _interopNamespaceDefault(e) {
	var n = Object.create(null);
	if (e) {
		Object.keys(e).forEach(function (k) {
			if (k !== 'default') {
				var d = Object.getOwnPropertyDescriptor(e, k);
				Object.defineProperty(n, k, d.get ? d : {
					enumerable: true,
					get: function () { return e[k]; }
				});
			}
		});
	}
	n.default = e;
	return Object.freeze(n);
}

var svg__namespace = /*#__PURE__*/_interopNamespaceDefault(svg);

const getAlicdnIconfont = () => {
  return new Promise((resolve, reject) => {
    vue.nextTick(() => {
      const styles = document.styleSheets;
      let sheetsList = [];
      let sheetsIconList = [];
      for (let i = 0; i < styles.length; i++) {
        if (styles[i].href && styles[i].href.indexOf("at.alicdn.com") > -1) {
          sheetsList.push(styles[i]);
        }
      }
      for (let i = 0; i < sheetsList.length; i++) {
        for (let j = 0; j < sheetsList[i].cssRules.length; j++) {
          if (sheetsList[i].cssRules[j].selectorText && sheetsList[i].cssRules[j].selectorText.indexOf(".icon-") > -1) {
            sheetsIconList.push(`${sheetsList[i].cssRules[j].selectorText.substring(1, sheetsList[i].cssRules[j].selectorText.length).replace(/\:\:before/gi, "")}`);
          }
        }
      }
      if (sheetsIconList.length == 0) {
        for (let i = 0; i < font_2298093_rnp72ifj3ba.iconfonntClassList.length; i++) {
          sheetsIconList.push(font_2298093_rnp72ifj3ba.iconfonntClassList[i]);
        }
      }
      if (sheetsIconList.length > 0) resolve(sheetsIconList);
      else reject("\u672A\u83B7\u53D6\u5230\u503C\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5");
    });
  });
};
const getElementPlusIconfont = () => {
  return new Promise((resolve, reject) => {
    vue.nextTick(() => {
      const icons = svg__namespace;
      const sheetsIconList = [];
      for (const i in icons) {
        sheetsIconList.push(`ele-${icons[i].name}`);
      }
      if (sheetsIconList.length > 0) resolve(sheetsIconList);
      else reject("\u672A\u83B7\u53D6\u5230\u503C\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5");
    });
  });
};
const getAwesomeIconfont = () => {
  return new Promise((resolve, reject) => {
    vue.nextTick(() => {
      const styles = document.styleSheets;
      let sheetsList = [];
      let sheetsIconList = [];
      for (let i = 0; i < styles.length; i++) {
        if (styles[i].href && styles[i].href.indexOf("netdna.bootstrapcdn.com") > -1) {
          sheetsList.push(styles[i]);
        }
      }
      for (let i = 0; i < sheetsList.length; i++) {
        for (let j = 0; j < sheetsList[i].cssRules.length; j++) {
          if (sheetsList[i].cssRules[j].selectorText && sheetsList[i].cssRules[j].selectorText.indexOf(".fa-") === 0 && sheetsList[i].cssRules[j].selectorText.indexOf(",") === -1) {
            if (/::before/.test(sheetsList[i].cssRules[j].selectorText)) {
              sheetsIconList.push(`${sheetsList[i].cssRules[j].selectorText.substring(1, sheetsList[i].cssRules[j].selectorText.length).replace(/\:\:before/gi, "")}`);
            }
          }
        }
      }
      if (sheetsIconList.length == 0) {
        for (let i = 0; i < fontAwesome.fontAwesomeClassList.length; i++) {
          sheetsIconList.push(fontAwesome.fontAwesomeClassList[i]);
        }
      }
      if (sheetsIconList.length > 0) resolve(sheetsIconList.reverse());
      else reject("\u672A\u83B7\u53D6\u5230\u503C\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5");
    });
  });
};
const initIconfont = {
  // iconfont
  ali: () => {
    return getAlicdnIconfont();
  },
  // element plus
  ele: () => {
    return getElementPlusIconfont();
  },
  // fontawesome
  awe: () => {
    return getAwesomeIconfont();
  }
};

exports.default = initIconfont;
