'use strict';

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

var vue = require('vue');
var elementPlus = require('element-plus');
var inputRandom = require('./input-random.js');
var index = require('../../svg-icon/index.js');

"use strict";
const _hoisted_1 = { class: "me-input-random" };
const __default__ = vue.defineComponent({
  name: "me-input-random"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: /* @__PURE__ */ vue.mergeModels({
    length: { type: Number, required: true, default: 4 },
    type: { type: Number, required: true, default: 0 }
  }, {
    "modelValue": { type: String },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const props = __props;
    const inputValue = vue.useModel(__props, "modelValue");
    const numCode = "1234567890";
    const litterCode = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
    const numLitterCode = numCode + litterCode;
    vue.onMounted(() => {
      if (!inputValue.value) {
        getRandomOfType();
      }
    });
    const getRandomOfType = () => {
      switch (props.type) {
        case inputRandom.RandomType.NUM:
          inputValue.value = getRandomRes(numCode);
          break;
        case inputRandom.RandomType.LITTER:
          inputValue.value = getRandomRes(litterCode);
          break;
        case inputRandom.RandomType.NUM_LITTER:
          inputValue.value = getRandomRes(numLitterCode);
          break;
        default:
          break;
      }
    };
    function getRandomRes(code) {
      let res = "";
      for (let i = 0; i < props.length; i++) {
        res += code.charAt(Math.floor(Math.random() * numCode.length));
      }
      return res;
    }
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(elementPlus.ElInput), {
          readonly: "",
          modelValue: inputValue.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
          style: { "max-width": "600px" },
          class: "input-with-select"
        }, {
          append: vue.withCtx(() => [
            vue.createElementVNode("div", {
              style: { "cursor": "pointer" },
              onClick: getRandomOfType
            }, [
              vue.createVNode(vue.unref(index.MeSvgIcon), { name: "ri-restart-line" })
            ])
          ]),
          _: 1
          /* STABLE */
        }, 8, ["modelValue"])
      ]);
    };
  }
});

exports.default = script;
//# sourceMappingURL=input-random.vue2.js.map
