"use strict";

exports.__esModule = true;
exports.getBaseAssets = getBaseAssets;
exports.getComponentImplFromWin = getComponentImplFromWin;
exports.getComponentImplUrl = getComponentImplUrl;
exports.getComponentSetterMap = getComponentSetterMap;
exports.getComponentSpecUrl = getComponentSpecUrl;
exports.isJsFunction = isJsFunction;
exports.isJsRunFunction = isJsRunFunction;
exports.transformStringToFunction = transformStringToFunction;
exports.uniqueId = uniqueId;
var guid = Date.now();
function uniqueId(prefix) {
  if (prefix === void 0) {
    prefix = '';
  }
  return "" + prefix + (guid++).toString(36).toLowerCase();
}
function getComponentImplUrl(info) {
  return "https://unpkg.com/" + info.npm + "@" + info.version + "/dist/index.min.js";
}
function getComponentSpecUrl(info) {
  return "https://unpkg.com/" + info.npm + "@" + info.version + "/asset/index.json";
}
function getBaseAssets() {
  return {
    js: ['https://g.alicdn.com/code/lib/react/17.0.2/umd/react.development.js', 'https://g.alicdn.com/code/lib/react-dom/17.0.2/umd/react-dom.development.js', 'https://unpkg.com/vitis-lowcode-simulator-renderer/dist/js/simulator-renderer.js'],
    css: ['https://unpkg.com/vitis-lowcode-simulator-renderer/dist/css/simulator-renderer.css']
  };
}
function getComponentSetterMap(win, bundle) {
  var name = bundle.packageName.replace(/-(\w)/g, function (s, m) {
    return m.toUpperCase();
  });
  return (win[name] || {}).setters || {};
}
function getComponentImplFromWin(win, bundle) {
  var name = bundle.packageName.replace(/-(\w)/g, function (s, m) {
    return m.toUpperCase();
  });

  //如果组件包中存在设置器
  if ((win[name] || {}).setters) {
    return (win[name] || {})["default"];
  } else {
    return win[name];
  }
}
function transformStringToFunction(str) {
  return new Function("\"use strict\"; return " + str)();
}
function isJsFunction(value) {
  return !!value && value.type === 'JSFunction';
}
function isJsRunFunction(value) {
  return !!value && value.type === 'JSRunFunction';
}