import { defineComponent, ref, watchEffect, openBlock, createElementBlock, createElementVNode, withDirectives, unref, vModelText, createVNode, createCommentVNode, toDisplayString, mergeProps } from "vue";
import { o as onDebounce } from "./index4.js";
import { _ as _sfc_main$2 } from "./index11.js";
var deleteIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAOiSURBVHgBzZrdceIwFIWvneTd+5iZJAMVZFNBTAdJBZstgQoCFaSEsBUkWwFsB2wFkJ+ZPC7vCbDneGTGFrYl2QL8zRiB/7jHku69khyIZ2azWYSigy06OjpiKcvlcq4OT7vd7kI8EkhDaHAYhnfYroMg+L5erztV5+P4HOdNUf6GsAkEzaUBtQXA8Pj4+PgeX2NpxgRifl1cXIykBs4CPBqegzWDYugqxFrAx8dH5+vr61E8G64DISM0raFt07ISoJ76E75GsgdUbfRRG8+mc0PTCW9vb/cwfix7Mp6gk3ewPfG/jedWHVQ3GMhhGZyfnw/LDpYKaInxKaUiCgW8vr7esAqlXfQgYqLv3BJAbwMvMDYFpAOwgBe80r3TVif+/PwctNB4EsGZPOo7cwLQdO7QdH5Ie4nRN+PsjpwA5DNGt9UCcjZuBPDp12k6DDrYbvHVJctc8BrU9lzcydXCRkCdpkPj0eF7jJi4vid2IhY8l9cg3e7VFLGphcQLqTxnJg6kxme9wvv7O9PpqqidGH92djZNd9T1erD3G8cWSQ3A88TiCP60r7s0GlZRE1vGk9PT0/lqteqLIxyDJKX6fSOO0KXxiev7S0QUGk94Dxx7FEdwTcwyEQA1l+JOxOZiIaLSeEOTqyKxOeCQEE/zn9Sn0kCWOzA+gf0gULn+WJpRKqIIH8YT/OeVcTxgSWlz0vFlPMF9ojCd+vCAUYRP4wldr68aOBhhZtKpKcZ+YIgTzjCKhycnJz5uZt2JfYsIEYXn0oxKN+oQ7JyBG52Gaq7yRephDFKWwc4Z5mKbXAg/rPy3hm2EjXYk4i8/UgETcQTX/HSIsJUieC9x55kfiQBkgyNx5wFRvJPdYfDzhSKYTiMXexBHOLPNMhGg+sHE5QacPUMQHKciLINUTkTdsQDO/5Om8tlANhRHMiJuHCJsIoJzTw2mb0YbG7J7MdakEbG0GHofDEe76W89lXCuhQOQszEnQE3dTaSlcO1AXwDZSuYwNqBL87oQ5wM1ibDVQrYEcJCN4lbaR79o1aYwnVZNqU39YVi2WmNa4BiINpV3AIZ4oIOyg8Y1sgOLqDSeWC3yMegw3O9x2p1O5LZoQUPHakiZzmNyQVp2DNMELmTYGE+cF7o5i81peN+1QcORmgxsDU+p/aoBhaDggsi1NKCu4SmNX/ZgRqkmh9lPLi1q5oUDKI5BmMY3fXulsQAdNVWZpMupGM4eYFtw/O37dZv/XhxunoTWr/gAAAAASUVORK5CYII=";
const _hoisted_1$1 = {
  class: "textarea-wrap bg-white",
  "data-weiling-mobile-ui-wl-textarea": ""
};
const _hoisted_2 = { class: "textarea flex-between" };
const _hoisted_3 = ["placeholder", "maxlength"];
const _hoisted_4 = {
  key: 0,
  class: "fs12 text-right text-base-color"
};
const __default__$1 = {
  name: "WlTextarea"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    modelValue: { default: "" },
    placeholder: { default: "" },
    clearable: { type: Boolean, default: true },
    needDebounce: { type: Boolean, default: true },
    maxlength: { default: null }
  },
  emits: ["onBlur", "onFocus", "onChange", "update:modelValue"],
  setup(__props, { expose, emit }) {
    const props = __props;
    const formValue = ref("");
    const textareaRef = ref(null);
    const onBlur = emit("onBlur");
    const onFocus = emit("onFocus");
    const onClear = () => emit("update:modelValue", "");
    const onTriggerFocus = () => {
      textareaRef.value.focus();
    };
    const onDebounceSave = onDebounce(() => {
      emit("onChange", formValue.value);
      emit("update:modelValue", formValue.value);
    }, 500);
    const onChange = () => {
      if (props.needDebounce) {
        onDebounceSave();
      } else {
        emit("onChange", formValue.value);
        emit("update:modelValue", formValue.value);
      }
    };
    watchEffect(() => {
      formValue.value = props.modelValue;
    });
    expose({
      onTriggerFocus
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$1, [
        createElementVNode("div", _hoisted_2, [
          withDirectives(createElementVNode("textarea", {
            type: "text",
            class: "textarea-base",
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formValue.value = $event),
            onInput: onChange,
            placeholder: __props.placeholder,
            ref_key: "textareaRef",
            ref: textareaRef,
            maxlength: __props.maxlength,
            onFocus: _cache[1] || (_cache[1] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
            onBlur: _cache[2] || (_cache[2] = (...args) => unref(onBlur) && unref(onBlur)(...args))
          }, null, 40, _hoisted_3), [
            [vModelText, formValue.value]
          ]),
          formValue.value && __props.clearable ? (openBlock(), createElementBlock("p", {
            key: 0,
            class: "pointer uno-w-18 uno-h-18",
            onClick: onClear
          }, [
            createVNode(_sfc_main$2, { src: unref(deleteIcon) }, null, 8, ["src"])
          ])) : createCommentVNode("", true)
        ]),
        __props.maxlength > 0 ? (openBlock(), createElementBlock("p", _hoisted_4, toDisplayString(formValue.value.length) + "/" + toDisplayString(__props.maxlength), 1)) : createCommentVNode("", true)
      ]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = { class: "wl-render-textarea" };
const __default__ = {
  name: "RfTextarea"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { default: "" }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const onInputChange = (val) => {
      emit("update:modelValue", val);
    };
    const inputValue = ref("");
    watchEffect(() => {
      inputValue.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_sfc_main$1, mergeProps({
          paddingLeft: 0,
          modelValue: inputValue.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
        }, _ctx.$attrs, {
          onOnChange: onInputChange,
          needDebounce: false
        }), null, 16, ["modelValue"])
      ]);
    };
  }
});
export { _sfc_main as default };
