"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
require("../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.js");
require("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
require("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js");
const image404 = require("../assets/images/exception/image-404.png.js");
require("../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js");
const type = require("./type.js");
const cloneDeep = require("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/cloneDeep.js");
const editPageEnum = require("../enums/editPageEnum.js");
const httpEnum = require("../enums/httpEnum.js");
const eventEnum = require("../enums/eventEnum.js");
const Icon = require("../../node_modules/.pnpm/naive-ui@2.34.3_vue@3.3.4/node_modules/naive-ui/es/icon/src/Icon.js");
const runtimeCore_esmBundler = require("../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const isDev = () => {
  return false;
};
const getUUID = (randomLength = 10) => {
  return Number(Math.random().toString().substring(2, randomLength) + Date.now()).toString(36);
};
const renderIcon = (icon, set = {}) => {
  return () => runtimeCore_esmBundler.h(Icon.NIcon, set, { default: () => runtimeCore_esmBundler.h(icon) });
};
const requireErrorImg = () => {
  return image404.default;
};
const setComponentPosition = (target, x, y) => {
  x && (target.attr.x = x);
  y && (target.attr.y = y);
};
const fileToUrl = (file) => {
  const Url = URL || window.URL || window.webkitURL;
  const ImageUrl = Url.createObjectURL(file);
  return ImageUrl;
};
const newFunctionHandle = (data, res, funcStr, isToString, errorCallBack, successCallBack) => {
  try {
    if (!funcStr)
      return data;
    const fn = new Function("data", "res", funcStr);
    const fnRes = fn(cloneDeep.default(data), cloneDeep.default(res));
    const resHandle = isToString ? type.toString(fnRes) : fnRes;
    successCallBack && successCallBack(resHandle);
    return resHandle;
  } catch (error) {
    errorCallBack && errorCallBack(error);
    return "函数执行错误";
  }
};
const intervalUnitHandle = (num, unit) => {
  switch (unit) {
    case httpEnum.RequestHttpIntervalEnum.SECOND:
      return num * 1e3;
    case httpEnum.RequestHttpIntervalEnum.MINUTE:
      return num * 1e3 * 60;
    case httpEnum.RequestHttpIntervalEnum.HOUR:
      return num * 1e3 * 60 * 60;
    case httpEnum.RequestHttpIntervalEnum.DAY:
      return num * 1e3 * 60 * 60 * 24;
    default:
      return num * 1e3;
  }
};
const setKeyboardDressShow = (keyCode) => {
  var _a, _b;
  const code = /* @__PURE__ */ new Map([
    [17, editPageEnum.WinKeyboard.CTRL],
    [32, editPageEnum.WinKeyboard.SPACE]
  ]);
  const dom = document.getElementById("keyboard-dress-show");
  if (!dom)
    return;
  if (!keyCode) {
    (_a = window.onKeySpacePressHold) == null ? void 0 : _a.call(window, false);
    dom.innerText = "";
    return;
  }
  if (keyCode && code.has(keyCode)) {
    if (keyCode == 32)
      (_b = window.onKeySpacePressHold) == null ? void 0 : _b.call(window, true);
    dom.innerText = `按下了「${code.get(keyCode)}」键`;
  }
};
const JSONStringify = (data) => {
  return JSON.stringify(
    data,
    (key, val) => {
      if (typeof val === "function") {
        return `${val}`;
      }
      if (typeof val === "undefined") {
        return null;
      }
      return val;
    },
    2
  );
};
const evalFn = (fn) => {
  var Fun = Function;
  return new Fun("return " + fn)();
};
const JSONParse = (data) => {
  return JSON.parse(data, (k, v) => {
    if (eventEnum.excludeParseEventKeyList.includes(k))
      return v;
    if (typeof v === "string") {
      const someValue = eventEnum.excludeParseEventValueList.some((excludeValue) => v.indexOf(excludeValue) > -1);
      if (someValue)
        return v;
    }
    if (typeof v === "string" && v.indexOf && (v.indexOf("function") > -1 || v.indexOf("=>") > -1)) {
      return evalFn(`(function(){return ${v}})()`);
    } else if (typeof v === "string" && v.indexOf && v.indexOf("return ") > -1) {
      const baseLeftIndex = v.indexOf("(");
      if (baseLeftIndex > -1) {
        const newFn = `function ${v.substring(baseLeftIndex)}`;
        return evalFn(`(function(){return ${newFn}})()`);
      }
    }
    return v;
  });
};
const setTitle = (title) => {
  title && (document.title = title);
};
exports.JSONParse = JSONParse;
exports.JSONStringify = JSONStringify;
exports.evalFn = evalFn;
exports.fileToUrl = fileToUrl;
exports.getUUID = getUUID;
exports.intervalUnitHandle = intervalUnitHandle;
exports.isDev = isDev;
exports.newFunctionHandle = newFunctionHandle;
exports.renderIcon = renderIcon;
exports.requireErrorImg = requireErrorImg;
exports.setComponentPosition = setComponentPosition;
exports.setKeyboardDressShow = setKeyboardDressShow;
exports.setTitle = setTitle;
